Oracle - 两个表中两行之间的差异或变化
我有两个表都有相同的架构,一个表有前一天的记录,另一个表有当前的记录。我想比较两者并仅查找更改或仅在至少一列中具有不同值的行。
这在pl/sql、oracle中怎么可能呢? (我在 T-SQL 中使用校验和编写了类似的代码,但不确定如何在 pl/sql 中执行)
I have two tables both have same schema, one will have previous day records other will have current. I want to compare both and find only changes or only rows that have different value in atleast one column.
How is this possible in pl/sql, oracle?
(I did code something similar using checksum in T-SQL but not sure how to do in pl/sql)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个SO答案提供了一个非常有效的解决方案,使用Oracle来比较2个查询的结果:证明SQL查询等价性
This SO answer provides a very efficient solution using Oracle to compare the results of 2 queries: Proving SQL query equivalency
正如 Dougman 发布的 之一比较两个数据集的最有效方法是将它们分组。我通常使用这样的查询来比较两个表:
As Dougman posted one of the most efficient way to compare two data sets is to GROUP them. I usually use a query like this to compare two tables:
您需要一个独占差异查询,它本质上是一个 (AB) U (BA) 查询:
还可以轻松改进此查询,以使用附加计算列显示哪些记录是插入、删除和更改。
You want an exclusive-difference query, which is is essentially an (A-B) U (B-A) query:
This query can also be easily improved to also show which records are inserts, deletes, and changes using an additional calculated column.