1. 程式人生 > >Oracle 空間表操作記錄

Oracle 空間表操作記錄

ont poi var key name 3.1 arc ron lec

刪除已建立的空間索引、空間表、空間表對象

drop index testinx;
drop table t_test_spatial;
delete from USER_SDO_GEOM_METADATA t where t.TABLE_NAME=‘T_TEST_SPATIAL‘;

創建空間數據表

create table t_test_spatial ( s_id varchar2(30) primary key, s_name varchar2(30), shape MDSYS.Sdo_Geometry );

定義空間表對像的空間範圍

insert into USER_SDO_GEOM_METADATA values(‘T_TEST_SPATIAL‘,‘SHAPE‘,SDO_DIM_ARRAY( SDO_DIM_ELEMENT(‘X‘, -180, 180, 0.005), SDO_DIM_ELEMENT(‘Y‘, -90, 90, 0.005)), 8307);

建立空間索引
create index testinx on T_TEST_SPATIAL(shape) INDEXTYPE IS MDSYS.SPATIAL_INDEX;

導入數據

insert into T_TEST_SPATIAL values(‘4‘,‘西湖路‘,sdo_geometry(‘POLYGON ((113.11258241 36.2203193573, 113.112198316 36.2178940792, 113.110130815 36.2180007719, 113.110043022 36.2206280549, 113.11258241 36.2203193573))‘,8307))

根據坐標查詢區域
SELECT c.區域名稱 FROM 區域表名稱 c WHERE SDO_CONTAINS(c.shape,SDO_GEOMETRY(2001, 4326,SDO_POINT_TYPE(經度值, 緯度值, NULL),NULL, NULL)) = ‘TRUE‘;

Oracle 空間表操作記錄