开发者

mysql LOAD DATA INFILE query problem

开发者 https://www.devze.com 2023-04-05 03:32 出处:网络
I am trying to load a dump file (csv) into mysql.. I am开发者_JAVA技巧 using the following query LOAD DATA LOCAL INFILE \'filename.csv\' INTO TABLE add_to_cart FIELDS TERMINATED BY \',\' LINES TERMIN

I am trying to load a dump file (csv) into mysql.. I am开发者_JAVA技巧 using the following query

LOAD DATA LOCAL INFILE 'filename.csv' INTO TABLE add_to_cart FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (fields...);

But it only returns me the first row... Why is it not going thru the complete csv file and simply giving me the first row. Thanks.


Are you sure the csv file has more than one line?

Then, if the csv file does indeed have multiple lines, does the first row in the output table correspond to the first line of the csv file? Or does it somehow happen that the first row of the output table corresponds to the final line of the csv file?


You probably need to change it from

LINES TERMINATED BY '\n'

to

LINES TERMINATED BY '\r\n'


Try to run the same command from Terminal and share the output.

If you are getting any value in skipped, as given below. Then the issue is in your table.

Query OK, 1 row affected, 65535 warnings (0.53 sec)

Records: 47355 Deleted: 0 Skipped: 4735 Warnings: 68411

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号