Luo Hao

Oracle——连接远程数据库

Rehoni / 2021-04-21


 sqlplus swgk/Nr_9000@10.151.51.251:1522/zhsjhl

tnsnames.ora文件中添加tns监听

 ORA-12504:TNS:监听程序在CONNECT_DATA中未获得SERVICE_NAME
 zhsjhl =
   (DESCRIPTION =
     (ADDRESS_LIST =
       (ADDRESS = (PROTOCOL = TCP)(HOST = 10.151.51.251)(PORT = 1522))
     )
     (CONNECT_DATA =
       (SERVICE_NAME = zhsjhl)
     )
   )

创建库之间的链接

 grant create public database link,create database link to huilk;
 create database link link1 connect to swgk identified by Nr_9000;
 create database link link2 connect to swgk identified by Nr_9000 using '
 (DESCRIPTION =
     (ADDRESS_LIST =
       (ADDRESS = (PROTOCOL = TCP)(HOST = 10.151.51.251)(PORT = 1522))
     )
     (CONNECT_DATA =
       (SERVICE_NAME = zhsjhl)
     )
   )';
 select * from SJHL_ZH.NZWOT_SP_SO_RISK_DESCRIPTION@link2;
 
 drop database link link1;