DB2使用IMPORT命令导入含有自增长列的表报错处理
https://www.cnblogs.com/OliverQin/p/7932553.html
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 使用自增
作者:奔跑的金鱼
欢迎任何形式的转载,但请务必注明出处。
限于本人水平,如果文章和代码有表述不当之处,还请不吝赐教。