【DB2】DB2使用IMPORT命令导入含有自增长列的表报错处理
1.启动数据库:db2start
2.创建数据库:create db TestDB using codeset gbk territory CN collate using identity
3.连接数据库:connect to TestDB user db2inst1 using db2inst1
4.创建表:create table TestTB(id integer not null generated always as identity(start with 1,increment by 1),name varchar(10))
5.数据文件如下:
5.1首先插入数据:
INSERT INTO TestTB(name) VALUES('zhangsan') INSERT INTO TestTB(name) VALUES('lisi')
5.2 导出数据
export to /home/oliver/TestTB.ixf of ixf select * from db2inst1.TestTB
5.3删除数据
delete from db2inst1.TestTB
5.4 导入已经导出数据
import from /home/oliver/TestTB.ixf of ixf insert into db2inst1.TestTB
结果报错了:
这就是由于表中存在自增字段导致错误,那么如何解决呢?
import from /home/oliver/TestTB.ixf of ixf modified by identityignore replace into db2inst1.TestTB
identityignore 忽略自增identitymissing 自动生成自增identityoverride 使用自增
作者:奔跑的金鱼
声明:书写博客不易,转载请注明出处,请支持原创,侵权将追究法律责任
个性签名:人的一切的痛苦,本质上都是对自己无能的愤怒
如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,博主在此感谢!