1

我正在尝试从制表符分隔的文本文件将几千条记录加载到我的 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 '" ' 中的引号后添加一个空格,但我仍然收到上面的错误消息。

我哪里错了?

4

1 回答 1

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);
于 2013-03-25T10:53:55.737 回答