mysqlで重複行を削除する
CREATE TEMPORARY TABLE tmp AS SELECT DISTINCT * FROM users;
DELETE FROM users;
INSERT INTO users SELECT * FROM tmp;
DROP TABLE tmp;
- DISTINCTで重複をマージしてSELECT > テンポラリ
- 元テーブル削除
- テンポラリ > 元テーブル
- テンポラリ削除
CREATE TEMPORARY TABLE tmp AS SELECT DISTINCT * FROM users;
DELETE FROM users;
INSERT INTO users SELECT * FROM tmp;
DROP TABLE tmp;
Powered by WordPress & Theme by Anders Norén
コメントを残す