Importing CSV to MySQL with Load Data Infile

时光毁灭记忆、已成空白 提交于 2019-12-11 08:55:24

问题


I'm trying to load a CSV file into MySQL, and I keep getting syntax errors:

load data infile 'c:/worldminwage.csv' fields terminated by ',' enclosed
by '"' lines terminated by '\n' (YearlyWage, PercentGDP, Date
effective);

Can anyone help me get this working? Thanks.


回答1:


Valid syntax is LOAD DATA INFILE 'c:/worldminwage.csv' INTO TABLE tablename.

You forgot to mention which table the data should go in. See LOAD DATA INFILE Syntax




回答2:


I think This would be more batter

LOAD DATA INFILE 'c:/worldminwage.csv' fields terminated by ',';

Because you will get rid of error like columns numbers are not matching in the .csv file and mysql table



来源:https://stackoverflow.com/questions/4485754/importing-csv-to-mysql-with-load-data-infile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!