MYSQL import data from csv using LOAD DATA INFILE

前端 未结 11 1530
感动是毒
感动是毒 2020-11-22 09:12

I am importing some data of 20000 rows from a CSV file into Mysql.

Columns in the CSV are in a different order than MySQL table\'s columns. How to automatically assi

11条回答
  •  [愿得一人]
    2020-11-22 09:43

    You probably need to set the FIELDS TERMINATED BY ',' or whatever the delimiter happens to be.

    For a CSV file, your statement should look like this:

    LOAD DATA INFILE 'data.csv' INTO TABLE tbl_name
    FIELDS TERMINATED BY ',' ENCLOSED BY '"'
    LINES TERMINATED BY '\r\n'
    IGNORE 1 LINES;
    

提交回复
热议问题