--创建表CREATETABLE my_shape_test (
id NUMBER PRIMARYKEY,
name VARCHAR2(32),
location SDO_GEOMETRY,
x84 number(20,10),
y84 number(20,10));--插入两条数据INSERTINTO my_shape_test VALUES(1,'point1',
SDO_GEOMETRY(2001,4326,
SDO_POINT_TYPE(115.60843803,32.1681994271,0),NULL,NULL),115.60843803,32.1681994271);INSERTINTO my_shape_test VALUES(2,'point2',
SDO_GEOMETRY(2001,4326,
SDO_POINT_TYPE(115.6094495600,32.1684263561,0),NULL,NULL),115.6094495600,32.1684263561);----------------------------------------------------------------------------- UPDATE METADATA VIEW -- 更新元数据视图----------------------------------------------------------------------------- Update the USER_SDO_GEOM_METADATA view. This is required-- before the spatial index can be created. Do this only once for each-- layer (that is, table-column combination; here: COLA_MARKETS and SHAPE).INSERTINTO user_sdo_geom_metadata
(TABLE_NAME,
COLUMN_NAME,
DIMINFO,
SRID)VALUES('my_shape_test','location',
SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X',-180,180,0.005),SDO_DIM_ELEMENT('Y',-90,90,0.005)),4326-- SRID);--------------------------------------------------------------------- CREATE THE SPATIAL INDEX --创建空间索引--------------------------------------------------------------------- Preceding statement created an R-tree index.CREATEINDEX my_shape_test_idx
ON my_shape_test(location)
INDEXTYPE IS MDSYS.SPATIAL_INDEX;