LOAD DATA
LOCAL INFILE "file.txt"
REPLACE INTO TABLE file
FIELDS TERMINATED BY '|'
(attribute1, attribute2)
LOAD DATA
LOCAL INFILE "file2.txt"
REPLACE INTO TABLE file2
FIELDS TERMINATED BY '|'
(attribute3, attribute4)
我有一个由几个“LOAD DATA”命令组成的文本文件。我收到一条错误消息,说第6行或第二个命令的开头是不正确的语法。如果我尝试引入“由'\ n''代码终止的行,它表示我的mysql版本不允许这样做。
答案 0 :(得分:1)
你应该加一个';'在每个加载语句的末尾。
LOAD DATA
LOCAL INFILE "file.txt"
REPLACE INTO TABLE file
FIELDS TERMINATED BY '|'
(attribute1, attribute2);
LOAD DATA
LOCAL INFILE "file2.txt"
REPLACE INTO TABLE file2
FIELDS TERMINATED BY '|'
(attribute3, attribute4);
另见ERROR 1148: The used command is not allowed with this MySQL version
您可以在设置客户端连接时将其指定为附加选项:
mysql -u myuser -p --local-infile somedatabase