【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