Oracle数据库同时查询两个数据库的两个表

本地数据库分别访问服务器上的两个数据库,对两个数据库的数据分别进行比较。

命令创建

create database link 随便起个名字
connect to 用户名 identified by 密码
using ‘(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 域名)(PORT = 端口号))
)
(CONNECT_DATA =
(SERVICE_NAME = 数据库实例名称)
)
)’;

实例填写

将A库和B库两个库之间的数据表进行关联进行对比,

create database link zlhis
  connect to zlhis identified by his
  using '(DESCRIPTION =                       
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = IP)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = zlhis)
    )
  )';

查询使用

 select * from 病案主页@zlhis
上一篇:视图函数


下一篇:TCP/IP