简单的话 假设id关联,A表纪录少 找出A表不存在,B表存在的纪录select B.* from B where not exists(select 'Z' from A where A.id=B.id)有个其他的方法 select A.id,B.id from A,B where A.id(+)=B.id and A.id is null如果2表都可能缺少 select A.*,'A' from A union select B.*,'B' from B minus select A.*,'AB' from A,B where A.id=B.id没测试,仅工参考
(select * from b minus select * from a) union (select * from a minus select * from b)
上半部分是 b中有 而 a 中没有的记录 下半部分是 a中有 而 b 中没有的记录用union 加起来 就是两个表中 全部不同的记录的集合
假设id关联,A表纪录少
找出A表不存在,B表存在的纪录select B.* from B
where not exists(select 'Z' from A where A.id=B.id)有个其他的方法
select A.id,B.id from A,B
where A.id(+)=B.id
and A.id is null如果2表都可能缺少
select A.*,'A' from A
union
select B.*,'B' from B
minus
select A.*,'AB' from A,B
where A.id=B.id没测试,仅工参考
union
(select * from a minus select * from b)
下半部分是 a中有 而 b 中没有的记录用union 加起来 就是两个表中 全部不同的记录的集合