我正在使用 LOAD DATA LOCAL INFILE 将数据导入 MySQL 表。我在另一张桌子上毫不费力地完成了这个,我复制了 stmt,只是更改了表名和字段。这是声明:
LOAD DATA LOCAL INFILE '/John/league_seasons.csv'
INTO TABLE lwl_league_players
IGNORE 1 LINES
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\r\n'
(id, location_id, game_id, league_season_id, player_id);
这是错误:
MySQL 说:文档
#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 'FIELDS TERMINATED BY ','
LINES TERMINATED BY '\r\n'
(id, location_id, game_id,' at line 4
FIELDS TERMINATED BY 和 LINES TERMINATED BY 行与我之前的工作语句完全相同。我检查了结构,没问题。
我很感激有人指出我搞砸了的地方。谢谢
选项的顺序很重要。
放置
IGNORE 1 LINES
后,接下来应该是列列表。请参阅有关语法的 MySQL 文档,您将看到选项的正确顺序。