问题现象
当 OceanBase 数据库 V4.x 版本的表中包含自增列,LOAD DATA INFILE 执行返回如下报错 ERROR 1366 (HY000): Incorrect integer value。
问题原因
导入文件中,自增列是为空值,导入到对应表的时候,对比认为导入的不是一个 integer value。
问题的风险及影响
文件内容不能导入。
影响租户
影响 OceanBase 数据库中的 SYS 租户和 MySQL 租户,对于 Oracle 租户无影响。
适用版本
OceanBase 数据库 V4.x 版本。
解决方法及规避方式
LOAD DATA INFILE 支持通过指定导入列的方式导入数据。对自增列,可以通过将自增列设置成变量或者设置初始值为0的方式导入,在导入中会被自动转成自增列对应值。
解决方法:
示例如下。
自增列设置成变量导入。
load data infile '/tmp/student.sql' into table student fields terminated by ',' (@c, name,score);设置初始值为 0。
load data infile '/tmp/student.sql' into table student fields terminated by ',' set id=0, name=@name, score=@score;查询导入数据的表 student 的内容。
obclient [test09]> select * from student;输出结果如下:
+----+-------+-------+ | id | name | score | +----+-------+-------+ | 1 | "lin" | 98 | | 2 | "hei" | 90 | | 3 | "ali" | 95 | +----+-------+-------+ 3 rows in set (0.078 sec)
规避方式:
通过使用旁路导入的方式,也可以导入包含自增列的数据。