识别两个表之间差异的最快方法? [英] Fastest way to identify differences between two tables?

查看:49
本文介绍了识别两个表之间差异的最快方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要对照事务性归档表检查活动表,但我不确定执行此操作的最快方法...

I have a need to check a live table against a transactional archive table and I'm unsure of the fastest way to do this...

例如,假设我的活动表由这些列组成:

For instance, let's say my live table is made up of these columns:

  • 条款
  • CRN
  • 费用
  • 级别代码

我的存档表将具有相同的列,但也具有存档日期,因此我可以查看活动表在给定日期具有的值.

My archive table would have the same columns, but also have an archive date so I can see what values the live table had at a given date.

现在...我将如何编写查询以确保活动表的值与存档表中的最新条目相同?

Now... How would I write a query to ensure that the values for the live table are the same as the most recent entries in the archive table?

PS我希望在SQL中处理此问题,但是PL/SQL如果速度更快,也是一种选择.

PS I'd prefer to handle this in SQL, but PL/SQL is also an option if it's faster.

推荐答案

SELECT term, crn, fee, level_code
FROM live_data
MINUS
SELECT term, crn, fee, level_code
FROM historical_data

现场直播,而不是历史直播.然后可以将其反过来获得历史上的内容,而不是真实的.

Whats on live but not in historical. Can then union to a reverse of this to get whats in historical but not live.

这篇关于识别两个表之间差异的最快方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆