ERROR 1064 LOAD DATA INFILE

时间:2013-03-25 10:36:50

标签: mysql

我正在尝试从制表符分隔的文本文件中将几千条记录加载到我的MySQL数据库中,但是我收到错误消息:

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 'FIELDS 
TERMINATED BY '\t' ENCLOSED BY '" '
LINES TERMINATED BY '\n'' at line 2

我的命令是:

LOAD DATA INFILE 'records.txt' INTO TABLE records (vendor, title, id, part, project,
description, machine, shelf, compartment, checkout)
FIELDS TERMINATED BY '\t' ENCLOSED BY '"'
LINES TERMINATED BY '\n';

我尝试了不同的选项,例如OPTIONALLY ENCLOSED BY''',LINES TERMINATED BY'\ r \ n',并在ENCLOSED BY'''的引号后面添加一个空格,但我仍然收到上面的错误消息

我哪里错了?

1 个答案:

答案 0 :(得分:2)

我不习惯这个命令,但我会说正确的查询是:

LOAD DATA INFILE 'records.txt' INTO TABLE records 
FIELDS TERMINATED BY '\t' ENCLOSED BY '"'
LINES TERMINATED BY '\n' (vendor, title, id, part, project,
description, machine, shelf, compartment, checkout);