点击上方“IT那活儿”,关注后了解更多内容,不管IT什么活儿,干就完了!!!
一
表空间backup-pending
copy on
copy yes
nonrecoverable
[db2i97@localhost ~]$ db2 connect to sample
[db2i97@localhost ~]$ db2 "create tablespace ts1"
[db2i97@localhost ~]$ db2 "create table t3 (id int,name char(20)) in ts1"

[db2i97@localhost ~]$ mkdir home/db2i97/archlog

[db2i97@localhost ~]$ db2 update db cfg for sample using LOGARCHMETH1 disk:/home/db2i97/archlog

[db2i97@localhost ~]$ db2 backup db sample to /dev/null


[db2i97@localhost ~]$ db2 "load from t3.del of del insert into t3"


[db2i97@localhost ~]$ db2 "update t3 set name='newcc' where id=3"

[db2i97@localhost ~]$ db2 list tablespaces show detail Tablespace ID = 7 Name = TS1 Type = Database managed space Contents = All permanent data. Large table space. State = 0x0020
[db2i97@localhost ~]$ db2 backup db sample tablespace ts1 online to /dev/null
Tablespace ID = 7 Name = TS1 Type = Database managed space Contents = All permanent data. Large table space. State = 0x0000 Detailed explanation: Normal
[db2i97@localhost ~]$ db2 "update t3 set name='newcc' where id=3"DB20000I The SQL command completed successfully.
[db2i97@localhost ~]$ db2 "load from t3.del of del insert into t3 nonrecoverable"
[db2i97@localhost ~]$ db2 list tablespaces show detail Tablespace ID = 7 Name = TS1 Type = Database managed space Contents = All permanent data. Large table space. State = 0x0000
二
表load pending
[root@localhost ~]# mkdir data1[root@localhost ~]# chown db2i97:db2i97 data1[db2i97@localhost ~]$ db2 "create tablespace ts3 pagesize 8k managed by database using (file '/data1/ts2' 256) bufferpool bp8k"[db2i97@localhost ~]$ db2 "create table t1 (id int, name char(50), desc char(150)) in ts1"
编写一个存储脚本sp_insert.sql:
[db2i97@localhost ~]$ vi sp_insert.sqlCREATE PROCEDURE sp_insert (IN count int) LANGUAGE SQLBEGIN DECLARE i INTEGER DEFAULT 0; while i<count do insert into t1 values( i, 'abcdefghixxxxxxxxxx' || char(i), 'bbbbbbbbbbbbbbbbbbbb'|| char(i) ); set i=i+1; end while;END@
[db2i97@localhost ~]$ db2 -td@ -f sp_insert.sqlDB20000I The SQL command completed successfully.[db2i97@localhost ~]$ db2 "call sp_insert(6500)" Return Status = 0[db2i97@localhost ~]$ db2 "export to t1.del of del select * from t1"SQL3104N The Export utility is beginning to export data to file "t1.del".SQL3105N The Export utility has finished exporting "6500" rows.Number of rows exported: 6500
重建一个大小为232页的表空间,将t1.del数据加载,由于无法分配新页,引起load出现异常。
[db2i97@localhost ~]$db2 "create tablespace ts1 pagesize 8k managed by database using (file '/data1/ts1' 232) bufferpool bp8k"[db2i97@localhost ~]$ db2 "create table t1 (id int, name char(50), desc char(50) ) in ts1"[db2i97@localhost ~]$db2 "load from t1.del of del insert into t1"[db2i97@localhost ~]$db2 load query table t1
db2 "SELECT TABSCHEMA, TABNAME, LOAD_STATUS FROM SYSIBMADM.ADMINTABINFO where load_status = 'PENDING'"

db2 "call sysproc.admin_cmd('Load from /dev/null of del terminate into db2i97.t1')"
END
本文作者:曹志铖
本文来源:IT那活儿(上海新炬王翦团队)

文章转载自IT那活儿,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




