由于所有建议的加载数据本地infile我也使用相同的查询,但我收到错误。
LOAD DATA LOCAL INFILE '/home/invensis/phygital_visualize/csv/originalcsv/lic.csv'
INTO TABLE li
FIELDS TERMINATED by ’,’
LINES TERMINATED BY ’n’
IGNORE 1 ROWS;
错误是
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '’,’
LINES TERMINATED BY ’n’
IGNORE 1 ROWS' at line 3
csv文件看起来像这样
NAME,JOB TITLE,DEPARTMENT,EMPLOYEE ANNUALSALARY,ESTIMATEDANNUALSALARYMINUSFURLOUGHS
"AARON, ELVIA J",WATER RATE TAKER,WATER MGMNT,$81000.00,$73862.00
"AARON, JEFFERY M",POLICE OFFICER,POLICE,$74628.00,$74628.00
"AARON, KIMBERLEI R",CHIEF CONTRACT EXPEDITER,FLEET MANAGEMNT,$77280.00,$70174.00
答案 0 :(得分:0)
使用“而不是':
LOAD DATA LOCAL INFILE '/home/invensis/phygital_visualize/csv/originalcsv/lic.csv'
INTO TABLE li
FIELDS TERMINATED by ","
LINES TERMINATED BY "\n"
IGNORE 1 ROWS;
另请注意,出于安全原因,mysql只允许从特定位置导入csv,例如/ tmp:https://dev.mysql.com/doc/refman/5.7/en/load-data-local.html
答案 1 :(得分:0)
错误消息告诉您 - 您在SQL中使用了’
而不是'
- 只需去编辑这些引号!
LOAD DATA LOCAL INFILE '/home/invensis/phygital_visualize/csv/originalcsv/lic.csv'
INTO TABLE li
FIELDS TERMINATED by ','
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;
另请注意,您可能希望终止为\n
而非文字n