MYSQL: Display Skipped records after LOAD DATA INFILE?

后端 未结 5 2142
被撕碎了的回忆
被撕碎了的回忆 2021-02-19 15:34

In MySQL I\'ve used LOAD DATA LOCAL INFILE which works fine. At the end I get a message like:

Records: 460377  Deleted: 0  Skipped: 145280  Warnings         


        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-19 16:17

    You could create a temp table removing the primary key items so that it allows duplications, and then insert the data.

    Construct a SQL statement like

    select count(column_with_duplicates) AS num_duplicates,column_with_duplicates
    from table
    group by column_with_duplicates
    having num_duplicates > 1;
    

    This will show you the rows with redundancies. Another way is to just dump out the rows that were actually inserted into the table, and run a file difference command against the original to see which ones weren't included.

提交回复
热议问题