How do I delete all the duplicate records in a MySQL table without temp tables

前端 未结 9 1216
北恋
北恋 2020-11-27 03:46

I\'ve seen a number of variations on this but nothing quite matches what I\'m trying to accomplish.

I have a table, TableA, which contain the answers gi

9条回答
  •  有刺的猬
    2020-11-27 04:32

    Instead of drop table TableA, you could delete all registers (delete from TableA;) and then populate original table with registers coming from TableA_Verify (insert into TAbleA select * from TAbleA_Verify). In this way you won't lost all references to original table (indexes,... )

    CREATE TABLE TableA_Verify AS SELECT DISTINCT * FROM TableA;
    
    DELETE FROM TableA;
    
    INSERT INTO TableA SELECT * FROM TAbleA_Verify;
    
    DROP TABLE TableA_Verify;
    

提交回复
热议问题