oracle 表字段对比,Oracle dblink比较两个库中的表字段

Oracle dblink比较两个库中的表字段

1

A库IP为10.0.30.65,olduser用户下有个表oldtable,该表只有一个列oldid。

B库IP为10.0.30.64,newuser用户下有个表newtable,该表只有一个列newid。

在A库中执行

create user olduser identified by old123;

grant connect, resource to olduser;

connect olduser/old123;

create table oldtable(oldid number);

insert into oldtable values(1);

insert into oldtable values(2);

insert into oldtable values(3);

commit;

在B库中执行

create user newuser identified by new123;

grant connect, resource to newuser;

connect newuser/new123;

create table newtable(newid number);

insert into newtable values(2);

insert into newtable values(3);

insert into newtable values(4);

commit;

2

B库的/u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora中配置连接A库的网络服务名old

OLD =

(DESCRIPTION =

(ADDRESS = (PROTOCOL =

TCP)(HOST = 10.0.30.65)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME =

orcl)

)

)

3

在B库中用system帐户创建远程连接A库的dblink

conn system/oracle

create public database link old_db connect to olduser identified

by old123 using 'old';

4

查找newtable中没有而oldtable中有的字段

conn newuser/new123;

select oldid from oldtable@old_db where oldid not in (select

newid from newtable);

OLDID

----------

1

5

查找oldtable中没有而newtable中有的字段

select newid from

newtable where newid not in (select oldid from oldtable@old_db);

NEWID

----------

4

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值