1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【PL/SQL】SELECT結果の差分確認(MINUS)

Last updated at Posted at 2019-03-25

#データの差分確認(MINUS)
##やりたいこと
SELECT結果の差分の取得
または
SELECT結果に差分が存在しないことの確認

##サンプルコード
MINUS関数は前後の項目が一致する場合に差分が存在するかを比較します。
差分の検出は(SELECT) - (SELECT)となるため、対応を逆にしてUNION ALLしています。

-- table_original - table_copy
SELECT * FROM table_original
MINUS
SELECT * FROM table_copy
UNION ALL
-- table_copy - table_original
SELECT * FROM table_copy
MINUS
SELECT * FROM table_original

##活用例
下記URLのテーブルコピーと併用し、同じテーブルで処理前後の差分比較などに使用します。
【PL/SQL】テーブルをまるごとコピー(CREATE TABLE SELECT)
レコード数が多い場合など、比較確認が難しい場合に便利です。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?