MySQL 5.7.26 不接受使用 Load Data Infile 的可空 int 列的 \N
MySQL 5.7.26 does not accept \N for nullable int column using Load Data Infile
MySQL 不接受 \N 值作为 null 当我确定我过去曾出于相同目的使用它时。
步骤:
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
我应该这样做的:
LOAD DATA infile '/var/lib/mysql-files/test.txt'
INTO TABLE t
fields terminated BY "\t"
Escaped by '\'
lines terminated BY "\r\n";
MySQL 不接受 \N 值作为 null 当我确定我过去曾出于相同目的使用它时。
步骤:
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
我应该这样做的:
LOAD DATA infile '/var/lib/mysql-files/test.txt'
INTO TABLE t
fields terminated BY "\t"
Escaped by '\'
lines terminated BY "\r\n";