db2haodb
作者db2haodb·2013-04-08 00:51
数据库开发工程师·IGI

数据移动

字数 2256阅读 1284评论 0赞 0
load---------------------------------------------------------------------------------------------
常用选项:
·COPY NO(缺省):不备份,Specifies that the table space in which the table resides will be placed in backup pending state if forward recovery is enabled (that is, logretain or userexit is on). The COPY NO option will also put the table space state into the Load in Progress table space state
·COPY YES   : 备份操作,Specifies that a copy of the loaded data will be saved. This option is invalid if forward recovery is disabled.
·NONREVERABLE :
不可覆盖,将 LOAD 操作标志为不可恢复,即数据库不能通过后续的前滚操作而被恢复,前滚操作会跳过这个事务并且把这个表标为“invalid”,这个操作也会忽略随后的所有的针对该表的事务,
对于这个操作,在执行load操作的时候,表空间不会出现backup pending(备份等待/挂起)的现象,并且已经load过的数据不会再做copy。
-------------********
说明:COPY YES和NONREVERABLE两项必须至少有一项,不然会出现“备份暂挂(load pending)”状态,
并且在操作数据的时候出现报错:SQL0290N  Table space access is not allowed.  SQLSTATE=55039;
可以通过list tablespaces show detail查看State,如果是“备份暂挂(load pending)”状态,可以:
这时需要备份下数据库就好了:
db2 "backup db conform tablespace (conform) online to /dev/null"
常用形式:
1.不做备份,直接不可覆盖导入数据(不会出现暂挂):
  load from test.del of del insert into test NONRECOVERABLE;
2.做备份(不会出现暂挂),会对整个sample数据库做备份(到当前目录):
E:TEST>db2 connect to sample
E:TEST>db2 load from staff.del of del insert into staff copy yes to .
E:TEST>db2 list tablespaces

此时可在当前目录下看到一个 SAMPLE.4 的子目录,表明产生的是一个由 LOAD 操作生成的备份,而这份备份将在数据库进行前滚恢复操作时用于重新创建 LOAD 操作对数据库的修改。如:
E:TEST>db2 restore db sample taken at 20051230174105
DB20000I RESTORE DATABASE 命令成功完成。
E:TEST>db2 rollforward db sample to end of logs and stop

export---------------------------------------------------------------------------------------------
语法:
export to myFile.del of del MESSAGES msg.out select a, b from tab_c where ....;
del数据的格式:colde10x0F decplusblank nochardel striplzeros
如:export to myFile.del of del modified by colde10x0F decplusblank nochardel striplzeros MESSAGES msg.out select a, b from tab_c where ....;


import---------------------------------------------------------------------------------------------
用法:
import from myFile.del of del/ixf/ insert/replace/insert_update into myTable;
commitcount n 每隔多少条提交一次
import from myFile.del of del commitcount 100 messages msg.out insert_update into myTable;
脱机导入: ALLOW NO ACCESS   联机导入:ALLOW WRITE ACCESS

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

0

添加新评论0 条评论

Ctrl+Enter 发表

作者其他文章

相关文章

相关问题

相关资料

X社区推广