MYSQL: Display Skipped records after LOAD DATA INFILE?

后端 未结 5 2145
被撕碎了的回忆
被撕碎了的回忆 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:32

    For anyone stumbling onto to this:

    Another option would be to do a SELECT INTO and diff the two files. For example:

    LOAD DATA LOCAL INFILE 'data.txt' INTO TABLE my_table FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\r' IGNORE 1 LINES (title, desc, is_viewable);
    
    SELECT title, desc, is_viewable INTO OUTFILE 'data_rows.txt' FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r' FROM my_table;
    

    Then execute FileMerge (on Mac OS X) data.txt data_rows.txt to see the differences. If you are getting an access denied error when doing the SELECT INTO make sure you:

    GRANT FILE ON *.* TO 'mysql_user'@'localhost';
    flush privileges;
    

    As the root user in the mysql client.

提交回复
热议问题