MySQL 5.7.26不接受\ N表示使用Load Data Infile可为空的int列

时间:2019-05-29 08:33:21

标签: ubuntu-16.04 mysql-5.7

当我确定过去出于相同的目的使用过\ N值时,MySQL不接受\ N值。

步骤:

CREATE TABLE t (i INT NULL, name varchar(50));

创建一个名为test.txt的文件,并用制表符分隔字段:

1   John
\N  Jim

在MySQL中:

LOAD DATA INFILE '/var/lib/mysql-files/test.txt'
INTO TABLE t
Fields terminated BY "\t"
Escaped by ''
Lines terminated BY "\r\n";

错误:

ERROR 1366 (HY000): Incorrect integer value: '\N' for column 'i' at row 2

1 个答案:

答案 0 :(得分:0)

我应该这样做:

LOAD DATA infile '/var/lib/mysql-files/test.txt'
INTO TABLE t
fields terminated BY "\t"
Escaped by '\\'
lines terminated BY "\r\n";