LOAD DATA LOCAL INFILE无法正常工作 - 找不到文件(MySQL Workbench)

时间:2015-06-24 12:26:02

标签: mysql sql mysql-workbench

我使用以下命令将excel文件加载到MySQL服务器:

LOAD DATA LOCAL INFILE 'GPMO_Resource_Download_report_CSV'
INTO TABLE gpmo_resource_download_report_1
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n';

我在以下路径的同一台机器上有这个文件:

C:\Users\aprakas2\Desktop\Task\GPMO_Resource_Download_report_CSV

请建议我如何加载此文件?

1 个答案:

答案 0 :(得分:0)

我认为这些SQL对你有用。

如果文件有标题行

LOAD DATA INFILE 'C:/Users/aprakas2/Desktop/Task/GPMO_Resource_Download_report_CSV' 
INTO TABLE gpmo_resource_download_report_1
FIELDS TERMINATED BY ',' 
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;

如果文件没有标题行

LOAD DATA INFILE 'C:/Users/aprakas2/Desktop/Task/GPMO_Resource_Download_report_CSV' 
INTO TABLE gpmo_resource_download_report_1
FIELDS TERMINATED BY ',' 
ENCLOSED BY '"'
LINES TERMINATED BY '\n';

谢谢。