db2import详解_DB2中import详解 - yishueitian326的日志 - 网易博客
提高import效率的方法:
1、如果是在分區(qū)數(shù)據(jù)庫的環(huán)境下,可以利用Buffered Insert來提高IMPORT的性能:
在執(zhí)行IMPORT命令前,要先用INSERT BUF參數(shù)重新綁定IMPORT命令對(duì)應(yīng)的綁定文件db2uimpm.bnd 。例如:
db2 connect to 數(shù)據(jù)庫名
db2 bind db2uimpm.bnd blocking all insert buf
db2uimpm.bnd在..sqllib\bnd目錄下。
2、執(zhí)行IMPORT命令時(shí)使用COMPOUND參數(shù):
例如:
db2 connect to 數(shù)據(jù)庫名
db2 import from 數(shù)據(jù)文件名 of ixf modified by compound=100 insert into 表名
上面的命令中IMPORT會(huì)在每100條記錄而不是每條記錄插入后等待返回的SQL執(zhí)行結(jié)果。
3、如果表中已有數(shù)據(jù),將表的屬性修改為APPEND MODE也可以加快IMPORT的性能。
4、設(shè)置commitcount 參數(shù)加快導(dǎo)入
db2 import from 數(shù)據(jù)文件名 of ixf modified by compound=100 commitcount 10000 insert into 表名
5、該用load可以提高4倍速度
(注意):有一次發(fā)現(xiàn)dos格式數(shù)據(jù)文件在linux導(dǎo)入時(shí)特別慢,在log文件中看見全是警告,轉(zhuǎn)換為nuix格式后速度提高10倍
import導(dǎo)入模式
1、在線模式-Online Import (ALLOW WRITE ACCESS)
1)應(yīng)用程序和import必須使用非獨(dú)占鎖(IX-nonexclusive lock),才可以在線導(dǎo)入,否則會(huì)相互等待,import可以顯式指定commit頻率或者使用AUTOMATIC選項(xiàng)。
db2 import from tbtest of ixf insert into tbtest ALLOW WRITE ACCESS COMMITCOUNT 5[或者AUTOMATIC]
2)在該模式下,import禁止使用REPLACE, CREATE 和 REPLACE_CREATE選項(xiàng)。
2、離線模式(缺省模式)-Offline Import (ALLOW NO ACCESS)
import啟動(dòng)后,要求獨(dú)占鎖(表鎖),如果應(yīng)用程序持有行鎖或表鎖,import將等待直到釋放
import導(dǎo)入舉例
1)指定某些列導(dǎo)入
數(shù)據(jù):
“Liszt”
“Hummel”,,187.43, H
“Grieg”,100, 66.34, G
“Satie”,101, 818.23, I
命令:
db2 import from datafile1.del of del method P(1, 3, 4) replace into table1 (c1, c3, c4)
2)按照固定列數(shù)導(dǎo)入,并使用null indicators選項(xiàng)
數(shù)據(jù):
1…5….10…15…20…25…30…35…40
Test.data.1………XXN.123abcdN
Test.data.2.and 3…QQY…wxyzN
Test.data.4,5.and.6.WWN6789.Y
命令:
db2 import from ascfile1 of asc
method L (1 20, 21 22, 24 27, 28 31)
null indicators (0, 0, 23, 32) #如果col1為null,插入0;如果col5為null,插入0;如果col2為null,插入23;如果col3為null,插入32;
insert into table1 (col1, col5, col2, col3)
3)skipcount與restartcount意義相同
db2 import from tbtest of del rowcount 100 insert into tbtest #導(dǎo)入前100條記錄
db2 import from tbtest of del skipcount/restartcount 100 insert into tbtest #從第101條記錄開始導(dǎo)入
db2 import from tbtest of del skipcount/restartcount 100 rowcount 100 insert into tbtest #從第101條記錄開始導(dǎo)入100條記錄
總結(jié)
以上是生活随笔為你收集整理的db2import详解_DB2中import详解 - yishueitian326的日志 - 网易博客的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 方正飞鸿智能信息平台产品白皮书(三)
- 下一篇: 系统启动时启动服务器,在BOIS如何设置