创建连接DBlink

创建连接DBlink

1.在本机oracle系统配串
HYORCLNEW =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.128.4.35)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.128.4.36)(PORT = 1521))
    (LOAD_BALANCE = yes)
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = hyorcl)
      (FAILOVER_MODE =
        (TYPE = select)
        (METHOD = basic)
        (RETRIES = 20)
        (DELAY = 1)
      )
    )
  )
2.

一 、创建dblink
Sql代码
create database link <DBLink名称> connect to <被连接库的用户名> identified by <被连接库的密码> using '<Oracle客户端工具建立的指向被连接库服务名>';

例如:

Sql代码
1.create database link XMDS_KF connect to XMDS identified by XMDS using 'HYORCLNEW ;  
 

但这种方式有个缺点就是必须要在服务器建立一个被连接库的服务名,如果不建则会报错:

ORA-12154: TNS: 无法处理服务名

,但如果直接使用地址来建DBLink,就可以省去配置服务名的麻烦了:

 

Sql代码
1.create public database link XMDS_KF connect to XMDS identified by XNDS using '(DESCRIPTION =  
2.   (ADDRESS_LIST =  
3.     (ADDRESS = (PROTOCOL = TCP)(HOST = 145.24.16.182)(PORT = 1521))  
4.   )  
5.   (CONNECT_DATA =  
6.     (SERVICE_NAME = XMDS)  
7.   )  
8. )'; 

你可能感兴趣的:(创建连接DBlink)