有两个库A和B,分别有一个一样的表name。 B库中name表的数据,是A库通过工具
传过来的。传过来之后,数据少了,请问通过什么语句能查出A库name表中有,但是B库name表中没有的数据,也就是丢失的数据。
连表查询,一个查询语句不就够了
select * from A.table where A.table.id not in (select id from B.table.id)
左外连接:select * from A a left join B b on a.id = b.id where a.name is not null and b.name is null
先在A建立B的DBlink,使用minus。
(select × from name)
minus
(select × from name@BDBLink)
minus 合并结果集得到的是差集