与SQLServer中链接服务器一个意思
可以在PLSQL中新建也可以直接SQL语句生成。
(1)PLSQL新建
在对象列表中找到 Database Link,右键,新建
录入数据库链接的名称,例如His,右边连接到,录入用户名\密码\数据库,这里数据库可以在tnsnames.ora文件中找到。
(2)SQL语句创建
create public database link dblinkname connect to username identified by password using '(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = database_ip)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME =servicename)))';
与上面PLSQL中可以对应起来:
数据库链接:
名称=dblinkname;
连接到:
用户名 = username
密码 = password
数据库 = (DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = database_ip)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME =servicename)))
与tnsNames.ora文件中某一个服务器设置对应起来:
dblinkname = (DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = database_ip)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME =servicename)))
使用服务器链接就很简单,要跨服务器访问某个表:
表名@dblinkname