0
0

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.

[mysql]処理前と処理後のデータを比較する(2つのテーブルの比較)

0
Posted at

内容

tableAを一括更新するバッチのリファクタリングをしたい
リファクタリング前後それぞれのバッチを実行した結果を比較したい
※tableAはすでにリファクタリング前バッチが実行された後の状態

実際にやったこと

  • tableAのコピーを作成する(tableA_beforeとする)
  • バッチ実行後のtableAとtableA_beforeを比較する

詳細

  • tableAのコピーを作成する(tableA_beforeとする)
mysql> create table tableA_before like tableA;
mysql> insert into tableA_before select * from table A;
  • バッチを実行する
    (実行に必要なコマンドを入力)

  • tableAとtableA_beforeを比較する

mysql>select
        tableA.id,
        tableA.columnA as columnA_after,
        tableA_before.columnA as columnA_before
    from tableA
        inner join tableA_before 
            on tableA.id = tableA_before.id
    where
        tableA.columnA != tableA_before.columnA;
  • テストのために作成したtableA_beforeを削除する
mysql> drop table tableA_before;
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?