首先通過PL sql在源數據庫A中建立到目標數據庫B的連接,語句如下:
drop database link orclAB;create shared database link orclAB connect to TargetUserName identified by "TargetUser密碼" AUTHENTICATED BY TargetUserName IDENTIFIED BY "TargetUser密碼" using ' (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.*.*.*)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = TargetServiceName) ) )';
建立好上述連接後,目標數據庫B中的表就可以在源數據庫A中直接使用;
在源數據庫A中查詢目標數據庫B表的語句如下,也就是在用友表名的後面增加@orclAB:
Select * from 目標數據庫表名@orclAB;
說明:orclAB:自定義的連接名;
TargetUserName:目標數據庫B登錄用戶名;
TargetUser密碼:目標數據庫B登錄密碼;
172.*.*.*:目標數據庫B所在機器的IP地址;
1521:目標oracle數據庫開放的端口;
TargetServiceName:目標oracle數據庫的服務名;