如何从csv中插入mysql中的记录?

时间:2016-10-20 10:44:21

标签: mysql csv

如何使用文件加载查询?

我尝试了这个查询:

LOAD DATA INFILE 'customer.csv' INTO TABLE customer

1 个答案:

答案 0 :(得分:2)

Syntax:

LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name' INTO TABLE `tbl_name` CHARACTER SET [CHARACTER SET charset_name] FIELDS [{FIELDS | COLUMNS}[TERMINATED BY 'string']] [LINES[TERMINATED BY 'string']]

Example:

LOAD DATA LOCAL INFILE 'E:\\wamp\\tmp\\customer.csv' INTO TABLE `customer` CHARACTER SET 'utf8' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n'