Oracle 5.0 Reference Manual page 1008

Table of Contents

Advertisement

5.0.16.) See also the annotations about spatial indexes under
Indexes".
• Use the
CREATE TABLE
CREATE TABLE geom (g GEOMETRY);
• Use the
ALTER TABLE
ALTER TABLE geom ADD pt POINT;
ALTER TABLE geom DROP pt;
12.16.4.4. Populating Spatial Columns
After you have created spatial columns, you can populate them with spatial data.
Values should be stored in internal geometry format, but you can convert them to that format
from either Well-Known Text (WKT) or Well-Known Binary (WKB) format. The following examples
demonstrate how to insert geometry values into a table by converting WKT values into internal
geometry format:
• Perform the conversion directly in the
INSERT INTO geom VALUES (GeomFromText('POINT(1 1)'));
SET @g = 'POINT(1 1)';
INSERT INTO geom VALUES (GeomFromText(@g));
• Perform the conversion prior to the INSERT:
SET @g = GeomFromText('POINT(1 1)');
INSERT INTO geom VALUES (@g);
The following examples insert more complex geometries into the table:
SET @g = 'LINESTRING(0 0,1 1,2 2)';
INSERT INTO geom VALUES (GeomFromText(@g));
SET @g = 'POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))';
INSERT INTO geom VALUES (GeomFromText(@g));
SET @g =
'GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(0 0,1 1,2 2,3 3,4 4))';
INSERT INTO geom VALUES (GeomFromText(@g));
The preceding examples all use
use type-specific functions:
SET @g = 'POINT(1 1)';
INSERT INTO geom VALUES (PointFromText(@g));
SET @g = 'LINESTRING(0 0,1 1,2 2)';
INSERT INTO geom VALUES (LineStringFromText(@g));
SET @g = 'POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))';
INSERT INTO geom VALUES (PolygonFromText(@g));
SET @g =
'GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(0 0,1 1,2 2,3 3,4 4))';
INSERT INTO geom VALUES (GeomCollFromText(@g));
Note that if a client application program wants to use WKB representations of geometry values, it is
responsible for sending correctly formed WKB in queries to the server. However, there are several
ways of satisfying this requirement. For example:
• Inserting a
mysql>
INSERT INTO geom VALUES
Creating a Spatially Enabled MySQL Database
statement to create a table with a spatial column:
statement to add or drop a spatial column to or from an existing table:
GeomFromText()
value with hex literal syntax:
POINT(1 1)
Section 12.16.6.1, "Creating Spatial
statement:
INSERT
[985]
to create geometry values. You can also
988

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents