以前有用户曾经问过这样一个问题 我想进行数据的关联,这很简单啊,ArcSDE提供了很多关联方式,join、视图、QueryLayer等, 详细参考:http://blog.csdn.net/linghe301/article/details/6649717 但是用户要求的条件比较特殊,这两个数据分布在两个库中,这可
以前有用户曾经问过这样一个问题
我想进行数据的关联,这很简单啊,ArcSDE提供了很多关联方式,join、视图、QueryLayer等,
详细参考:http://blog.csdn.net/linghe301/article/details/6649717
但是用户要求的条件比较特殊,这两个数据分布在两个库中,这可以进行关联么?答案是肯定的。下面我们就一一演示一下怎么进行跨库的关联,其实关键的步骤就是Oracle数据库的跨库查询,其他方面就跟一个库一样了。
比如我们有一个库orcl里面用户test的表为place,另外一个库orcl2里面用户sde的表为owner
首先我们看看这两个表的结构
C:\Users\Administrator>sqlplus test/test@orcl SQL*Plus: Release 11.2.0.1.0 Production on 星期一 2月 6 15:50:04 2012 Copyright (c) 1982, 2010, Oracle. All rights reserved. 连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> desc place; 名称 是否为空? 类型 ----------------------------------------- -------- -------------------------- OBJECTID NOT NULL NUMBER(38) NAME NVARCHAR2(50) PID NUMBER(38) ID NUMBER(38) SHAPE SDE.ST_GEOMETRY
查看另外一个实例,看owner的结构
C:\Users\Administrator>sqlplus sys/oracle@orcl2 as sysdba SQL*Plus: Release 11.2.0.1.0 Production on 星期一 2月 6 15:50:52 2012 Copyright (c) 1982, 2010, Oracle. All rights reserved. 连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> desc sde.owner; 名称 是否为空? 类型 ----------------------------------------- -------- ------------------------- OBJECTID NOT NULL NUMBER(38) PID NUMBER(10) ID NUMBER(10) NAME NVARCHAR2(50) NAME1 NVARCHAR2(50)place是空间表,owner为属性表,这两个表的ID为关联字段
首先我们将这两个表在数据库层次上进行关联
create public database link ABB connect to SDE using 'orcl2';
create public database link ABC connect to SDE using '(DESCRIPTION= (ADDRESS_LIST= (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.111)(PORT=1521)) ) (CONNECT_DATA= (SERVICE_NAME=orcl2) ) )';
以上两种关联方法都可以,具体步骤就是我连接实例orcl的sys用户,然后其中ABB是你建树的dblink名字,orcl2是远程数据库的实例名/网络服务名,sde/sde是登录到远程数据库的用户/密码。然后在当地数据库中经由过程dblink访谒远程数据库'orcl2'中
那么我们在一个实例查看另一个实例的某个用户的表名应该是:
用户名.表名@数据库连接名(上面的link名称)
SQL> conn sys/oracle@orcl as sysdba 已连接。 SQL> create public database link ABB connect to sde identified by sde using 'orcl2'; 数据库链接已创建。 SQL> desc sde.owner@ABB; 名称 是否为空? 类型 ----------------------------------------- -------- ---------------------------- OBJECTID NOT NULL NUMBER(38) PID NUMBER(10) ID NUMBER(10) NAME NVARCHAR2(50) NAME1 NVARCHAR2(50)
SQL> conn sys/oracle@orcl as sysdba 已连接。 SQL> create public database link ABB connect to sde identified by sde using 'orcl2'; 数据库链接已创建。 SQL> desc sde.owner@ABB; 名称 是否为空? 类型 ----------------------------------------- -------- ---------------------------- OBJECTID NOT NULL NUMBER(38) PID NUMBER(10) ID NUMBER(10) NAME NVARCHAR2(50) NAME1 NVARCHAR2(50)
尽量创建public,不然针对不同用户有权限的问题,如果对权限要求很高,也可以不使用public
那么我们创建相关的视图
SQL> create or replace view myview1 as select test.place.pid,test.place.shape,sde.owner@ABB.name from test.place,sde.own er@ABB where test.place.id=sde.owner@ABB.id; create or replace view myview1 as select test.place.pid,test.place.shape,sde.owner@ABB.name from test.place,sde.owner@AB B where test.place.id=sde.owner@ABB.id * 第 1 行出现错误: ORA-02019: 未找到远程数据库的连接说明 ORA-04054: 数据库链接 ABB.ID 不存在
可见在orcl实例下直接使用sde.owner@ABB.id获得orcl2实例里面的owner表中的id字段系统不支持,那我们将sde.owner@ABB在orcl实例下创建一个同义词来代替。
创建同义词
SQL> conn sys/oracle@orcl as sysdba 已连接。 SQL> create public synonym mysyn1 for sde.owner@abb; 同义词已创建。 SQL> conn test/test@orcl; 已连接。 SQL> desc mysyn1; 名称 是否为空? 类型 ----------------------------------------- -------- ---------------------------- OBJECTID NOT NULL NUMBER(38) PID NUMBER(10) ID NUMBER(10) NAME NVARCHAR2(50) NAME1 NVARCHAR2(50)
创建视图
SQL> create or replace view myview1 as select test.place.pid,test.place.shape,mysyn1.name from test.place,mysyn1 where test.place.id=mysyn1.id; 视图已创建。
ArcSDE注册
C:\Users\Administrator>sdelayer -o register -l myview1,shape -e a -t ST_GEOMETRY -i sde:oracle11g:orcl -u test -p test ArcSDE 10.0 for Oracle11g Build 1937 Tue Aug 16 16:08:18 2011 Layer Administration Utility ----------------------------------------------------- Successfully Created Layer.
结束语:个人感觉,这种方式来进行关联不太稳定,至少我将该图层数据加载到ArcGIS Desktop导致桌面软件崩溃(也有可能因为我环境问题导致的),不过使用sql操作都没有问题,不是万不得已,建议慎重考虑使用该方式。

MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

Dreamweaver Mac version
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
