两张表 A B
字段 时间 fdate 金额 fee
想比对两个表的差异
方式1
select from a minus select from b
union
select from b minus select from a
方式2
select * from a,b where a.fdate=b.fdate and a.fee<>b.fee
哪种方式最好呢? 数据量大的时候 效率方面呢?
两张表 A B
字段 时间 fdate 金额 fee
想比对两个表的差异
方式1
select from a minus select from b
union
select from b minus select from a
方式2
select * from a,b where a.fdate=b.fdate and a.fee<>b.fee
哪种方式最好呢? 数据量大的时候 效率方面呢?
1 回答2.4k 阅读✓ 已解决
1 回答2.3k 阅读✓ 已解决
1.4k 阅读
如果需要比较多个列的数据是否一致,且需要查看具体的差异信息,可以使用 JOIN 方式;如果只需要比较两张表的数据是否完全一致,使用 MINUS 方式。
在两张表中都有大量数据的情况下,JOIN效率可能不如 MINUS 方式。