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.

SQL 更新前と更新後のテーブルの状態を比較する

Last updated at Posted at 2020-08-18

合ってそうだけどダメなやり方

mysqldump -u admin -h hostname -ppassword DBname tablename > before.ret

//ここで何かしらの更新処理

mysqldump -u admin -h hostname -ppassword DBname tablename > after.ret

diff before.ret after.ret

正しいやり方

mysqldumpを使わず、select文の結果を出力して比較します


mysql -u admin -h hostname -ppassword DBname < select_tablename.sql > before.ret

//ここで何かしらの更新処理

mysql -u admin -h hostname -ppassword DBname < select_tablename.sql > after.ret

diff before.ret after.ret

▼select_tablename.sqlの中身

select * from tablename;
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?