首先通过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数据库的服务名;