MySQL LOAD DATA 具有多行数据
我在使用 Mysql 的 LOAD DATA 命令时遇到问题。
使用简单的数据,它就可以正常工作。
当我尝试加载很长并且有一个跨越多行的字段的数据时,它会失败。
这是我的输入数据。字段以制表符分隔。
1 2008-06-27 12:00:00 Type-Safe Enumerations title Fr 5
...line 1..
...line 2....
\N 2002-10-01 12:00:00 END-OF-THE-LINE
2 2008-06-27 12:00:00 Class for constants Classe pour constantes 1
line 1...
..line 2..
\N 2002-10-01 12:00:00 END-OF-THE-LINE
4 2008-06-27 12:00:00 Another Énumérations 5
line 1
line 2
\N 2002-10-01 12:00:00 END-OF-THE-LINE
5 2008-06-27 12:00:00 And Another Énumérations 5
line 1
line 2
\N 2002-10-01 12:00:00 END-OF-THE-LINE
这是 LOAD DATA 命令:
>LOAD DATA LOCAL INFILE "TopicInfileText2.dat" INTO TABLE Topic
LINES TERMINATED BY "END-OF-THE-LINE";
目标表:
CREATE TABLE Topic (
Id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
LastEdit TIMESTAMP NOT NULL,
TitleEnglish VARCHAR(75) NOT NULL,
TitleFrench VARCHAR(75),
ChapterId SMALLINT NOT NULL References Chapter,
BodyEnglish TEXT NOT NULL,
BodyFrench TEXT,
CreationDate DATETIME NOT NULL,
PRIMARY KEY (Id)
);
来自 MySQL 的警告
| Incorrect integer value: '
2' for column 'Id' at row 2 |
| Incorrect integer value: '
4' for column 'Id' at row 3 |
| Warning | 1366 | Incorrect integer value: '
5' for column 'Id' at row 4 |
| Warning | 1366 | Incorrect integer value: '
' for column 'Id' at row 5 |
I'm having problems with Mysql's LOAD DATA command.
With simple data, it works fine.
When I try to load in data which is long, and has a field which extends over many lines, it fails.
Here's my input data. Fields are tab-delimited.
1 2008-06-27 12:00:00 Type-Safe Enumerations title Fr 5
...line 1..
...line 2....
\N 2002-10-01 12:00:00 END-OF-THE-LINE
2 2008-06-27 12:00:00 Class for constants Classe pour constantes 1
line 1...
..line 2..
\N 2002-10-01 12:00:00 END-OF-THE-LINE
4 2008-06-27 12:00:00 Another Énumérations 5
line 1
line 2
\N 2002-10-01 12:00:00 END-OF-THE-LINE
5 2008-06-27 12:00:00 And Another Énumérations 5
line 1
line 2
\N 2002-10-01 12:00:00 END-OF-THE-LINE
And here's the LOAD DATA command:
>LOAD DATA LOCAL INFILE "TopicInfileText2.dat" INTO TABLE Topic
LINES TERMINATED BY "END-OF-THE-LINE";
The target table :
CREATE TABLE Topic (
Id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
LastEdit TIMESTAMP NOT NULL,
TitleEnglish VARCHAR(75) NOT NULL,
TitleFrench VARCHAR(75),
ChapterId SMALLINT NOT NULL References Chapter,
BodyEnglish TEXT NOT NULL,
BodyFrench TEXT,
CreationDate DATETIME NOT NULL,
PRIMARY KEY (Id)
);
Warnings from MySQL
| Incorrect integer value: '
2' for column 'Id' at row 2 |
| Incorrect integer value: '
4' for column 'Id' at row 3 |
| Warning | 1366 | Incorrect integer value: '
5' for column 'Id' at row 4 |
| Warning | 1366 | Incorrect integer value: '
' for column 'Id' at row 5 |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
错误出现在 LOAD DATA 命令中。我缺少一个换行符。
应该是:
The error was in the LOAD DATA command. I was missing a newline character.
Should have been: