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