Oralce Spatial
1.建立数据库连接
create public database link ytlink connect to hightop identified by hightop using '(DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.2.137)(PORT=1521)) (CONNECT_DATA= (SERVER = DEDICATED)(SERVICE_NAME = orcl)) )';
2.跨库查询
select * from police@ytlink
3.创建临时表空间
create temporary tablespace POLICE_TEMP --创建临时表空间 tempfile 'E:\app\Administrator\product\POLICE_TEMP.dbf' size 50m autoextend on next 50m maxsize 20480m extent management local;
4.删除表空间
drop tablespace POLICE_TEMP including contents and datafiles;--删除表空间
5.创建表空间
create tablespace POLICE --创建表空间 logging datafile 'E:\app\Administrator\product\POLICE.dbf' size 500m autoextend on next 500m maxsize 20480m extent management local;
6.创建用户
create user hightop identified by "hightop" --创建用户并制定表空间 default tablespace POLICE temporary tablespace POLICE_TEMP;
7.删除用户
drop user hightop cascade;--删除用户
8.用户授权
grant all privileges to hightop;--给用户授予权限
9.shp上传oracle
1.shp2sdo shp文件名 表名 -i id -s 4326 -d(在shp2sdo所在路径下执行) 2.SQL> @J:\DY\表名.sql(在plsql的sql命令行执行或sqlplus下执行) 3.sqlldr 用户名/密码@实例名 表名(在安装oracle机器的dos执行) 4.SQL> execute sdo_migrate.to_current('表名','geometry字段名'); 5.SQL> CREATE INDEX 索引名 ON 表名(geometry字段名) INDEXTYPE IS MDSYS.SPATIAL_INDEX;
10.空间关系计算
select c.id,s.id from tlmap_village c,cameragps s where sdo_geom.relate(s.geom,'Anyinteract',c.geom,0.000001)='TRUE' --计算点在面内
11.向mdsys.cs_srs中插入crs(以3857为例):
insert into mdsys.cs_srs (cs_name, srid, auth_srid, wktext, wktext3d) values ( 'WGS_1984_Web_Mercator_Auxiliary_Sphere', 3857, 3857, 'PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]]', '' );
12.SDO_SRID不为NULL时,SDO_SRID必须在MDSYS.CS_SRS 表中的 SRID 列有对应的值,而且它的值必须插入USER_SDO_GEOM_METADATA视图中。