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