Home Database Mysql Tutorial ArcSDE进行跨数据库的关联

ArcSDE进行跨数据库的关联

Jun 07, 2016 pm 03:48 PM
association database user conduct

以前有用户曾经问过这样一个问题 我想进行数据的关联,这很简单啊,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
Copy after login

查看另外一个实例,看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)
Copy after login
place是空间表,owner为属性表,这两个表的ID为关联字段

首先我们将这两个表在数据库层次上进行关联

create public database link ABB
  connect to SDE
  using 'orcl2';
Copy after login


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)
)
)';
Copy after login

以上两种关联方法都可以,具体步骤就是我连接实例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)
Copy after login
Copy after login
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)
Copy after login
Copy after login


尽量创建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 不存在
Copy after login

可见在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)
Copy after login

创建视图
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;

视图已创建。
Copy after login

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.
Copy after login





结束语:个人感觉,这种方式来进行关联不太稳定,至少我将该图层数据加载到ArcGIS Desktop导致桌面软件崩溃(也有可能因为我环境问题导致的),不过使用sql操作都没有问题,不是万不得已,建议慎重考虑使用该方式。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1665
14
PHP Tutorial
1270
29
C# Tutorial
1250
24
iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

How to handle database connection errors in PHP How to handle database connection errors in PHP Jun 05, 2024 pm 02:16 PM

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

How to use database callback functions in Golang? How to use database callback functions in Golang? Jun 03, 2024 pm 02:20 PM

Using the database callback function in Golang can achieve: executing custom code after the specified database operation is completed. Add custom behavior through separate functions without writing additional code. Callback functions are available for insert, update, delete, and query operations. You must use the sql.Exec, sql.QueryRow, or sql.Query function to use the callback function.

How to save JSON data to database in Golang? How to save JSON data to database in Golang? Jun 06, 2024 am 11:24 AM

JSON data can be saved into a MySQL database by using the gjson library or the json.Unmarshal function. The gjson library provides convenience methods to parse JSON fields, and the json.Unmarshal function requires a target type pointer to unmarshal JSON data. Both methods require preparing SQL statements and performing insert operations to persist the data into the database.

PHP connections to different databases: MySQL, PostgreSQL, Oracle and more PHP connections to different databases: MySQL, PostgreSQL, Oracle and more Jun 01, 2024 pm 03:02 PM

PHP database connection guide: MySQL: Install the MySQLi extension and create a connection (servername, username, password, dbname). PostgreSQL: Install the PgSQL extension and create a connection (host, dbname, user, password). Oracle: Install the OracleOCI8 extension and create a connection (servername, username, password). Practical case: Obtain MySQL data, PostgreSQL query, OracleOCI8 update record.

How to handle database connections and operations using C++? How to handle database connections and operations using C++? Jun 01, 2024 pm 07:24 PM

Use the DataAccessObjects (DAO) library in C++ to connect and operate the database, including establishing database connections, executing SQL queries, inserting new records and updating existing records. The specific steps are: 1. Include necessary library statements; 2. Open the database file; 3. Create a Recordset object to execute SQL queries or manipulate data; 4. Traverse the results or update records according to specific needs.

How to connect to remote database using Golang? How to connect to remote database using Golang? Jun 01, 2024 pm 08:31 PM

Through the Go standard library database/sql package, you can connect to remote databases such as MySQL, PostgreSQL or SQLite: create a connection string containing database connection information. Use the sql.Open() function to open a database connection. Perform database operations such as SQL queries and insert operations. Use defer to close the database connection to release resources.

See all articles