Loading data into mysql ignore first line
I am trying to load some data from a text file into mysql. I would like to ignore the first line.
From the mysql 5.5 manual, there is a "ignore 1 line" option.
I have tried using this query to no avail:
LOAD DATA LOCAL INFILE 'iso开发者_C百科-languagecodes.txt' INTO TABLE iso_languagecodes (iso_639_3, iso_639_2, iso_639_1, language_name) IGNORE 1 LINES;
Can anyone point out what is wrong?
This is the error I am receiving
ERROR 1064 (42000): 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 ' IGNO
RE 1 LINES' at line 1
The following 2 queries will work:
LOAD DATA LOCAL INFILE 'iso-languagecodes.txt' INTO TABLE iso_languagecodes (iso_639_3, iso_639_2, iso_639_1, language_name);
or
LOAD DATA LOCAL INFILE 'iso-languagecodes.txt' INTO TABLE iso_languagecodes IGNORE 1 LINES;
But, I need to be able to specify the columns and ignore the first line.
For those interested, here is the final solution:
LOAD DATA LOCAL INFILE 'iso-languagecodes.txt' INTO TABLE iso_languagecodes IGNORE 1 LINES (iso_639_3, iso_639_2, iso_639_1, language_name);
Try this:
LOAD DATA LOCAL INFILE 'iso-languagecodes.txt' INTO TABLE iso_languagecodes (iso_639_3, iso_639_2, iso_639_1, language_name) FIELDS TERMINATED BY ',' IGNORE 1 LINES;
Replace the ',' for whatever delimiter you are using in your file; use '\t' for tabs
精彩评论