【DB2】DB2使用IMPORT命令导入含有自增长列的表报错处理


1.启动数据库:db2start

image

2.创建数据库:create db TestDB using codeset gbk territory CN  collate using identity

image

3.连接数据库:connect to TestDB user db2inst1 using db2inst1

image

4.创建表:create table TestTB(id integer not null generated always as identity(start with 1,increment by 1),name varchar(10))

image

5.数据文件如下:

5.1首先插入数据:

INSERT INTO TestTB(name) VALUES('zhangsan')
INSERT INTO TestTB(name) VALUES('lisi')

image

5.2 导出数据

export to /home/oliver/TestTB.ixf of ixf select * from db2inst1.TestTB

image

5.3删除数据

delete from db2inst1.TestTB

image

5.4 导入已经导出数据

import from /home/oliver/TestTB.ixf of ixf insert into db2inst1.TestTB

结果报错了:

image

这就是由于表中存在自增字段导致错误,那么如何解决呢?

import from /home/oliver/TestTB.ixf of ixf modified by identityignore replace into  db2inst1.TestTB

image

identityignore 忽略自增identitymissing 自动生成自增identityoverride 使用自增


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM