Trying to do LOAD DATA INFILE with REPLACE and AUTO_INCREMENT

前端 未结 3 1902
太阳男子
太阳男子 2020-12-30 01:15

I am trying to load a file onto a MySQL database, having the primary key auto_incremented and I would like the data to be updated if i find any duplicate rows. However, the

3条回答
  •  猫巷女王i
    2020-12-30 01:54

    Just delete the REPLACE from the LOAD DATA, execute it twice and you will get the desired result:

    LOAD DATA LOCAL INFILE 'C:/testData.txt'
    INTO TABLE TEST
    FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
    LINES TERMINATED BY '\r\n'
    IGNORE 1 LINES
    (NAME, VALUE);
    

    I suppose you don't really want the desired result you've posted, do you?

提交回复
热议问题