1.使用minus,使用集合求差,如果返回的记录集为空,代表记录完全一样 select * from a minus select * from b 2.使用not exists.效率高。 select * from a where not exists (select * from b where a.col1=b.col2 and a.col2=b.col2 ......)
MERGE一下,如果存在更新和插入就说明存在差异
1.根据主key关系,求存在 select * from A exists (select 1 from B where A.id = B.id)2.求交集minus
select * from a
minus
select * from b
2.使用not exists.效率高。
select * from a where not exists (select * from b where a.col1=b.col2 and a.col2=b.col2 ......)
1.根据主key关系,求存在
select * from A exists (select 1 from B where A.id = B.id)2.求交集minus
数据对比使用楼上方式是可以的,关键你要的比较结果达到什么程度?
如果只是判断数据相同否,写存储过程使用动态SQL就行了。
要比较明细,做一个类似beyond compare的完善工具?难。
按照主键,来个out join,然后筛选想比对的非主键列就可以了
select * from tba minus select * from tbb
union all
select * from tbb minus select * from tba--有数据则不相同,木有则相同
select * from tba minus select * from tbb
union all
select * from tbb minus select * from tba这样效率怎么样?????
用 not exists 也行吗!