db2move export/import逻辑导出导入(整个库)

环境:
OS:Centos 7
DB:11.5.6

 

1.导出备份
[db2inst1@localhost /]$ mkdir -p /tmp/mybak
[db2inst1@localhost /]$ cd /tmp/mybak

[db2inst1@localhost mybak]$ db2move db_hxl export
[db2inst1@localhost mybak]$ ls
db2move.lst tab1.ixf tab2.ixf tab3a.001.lob tab3.msg tab4.msg tab5.msg
EXPORT.out tab1.msg tab2.msg tab3.ixf tab4.ixf tab5.ixf

这个时候会生成这些文件,db2move.lst文件记录了文件名对应的表关系
[db2inst1@localhost mybak]$ more db2move.lst
!"SYSTOOLS"."HMON_ATM_INFO"!tab1.ixf!tab1.msg!
!"SYSTOOLS"."HMON_COLLECTION"!tab2.ixf!tab2.msg!
!"SYSTOOLS"."POLICY"!tab3.ixf!tab3.msg!
!"DB2INST1"."TB_TEST01"!tab4.ixf!tab4.msg!
!"DB2INST1"."TB_TEST02"!tab5.ixf!tab5.msg!

 

2.模拟删除数据库
[db2inst1@localhost mybak]$ db2 terminate
[db2inst1@localhost mybak]$ db2 "drop database db_hxl"

 

3.恢复数据库
先创建数据库
db2 create db db_hxl using codeset utf-8 territory CN
[db2inst1@localhost mybak]$ cd /tmp/mybak
[db2inst1@localhost mybak]$ db2move db_hxl import

同样的库恢复到另外的库
[db2inst1@localhost mybak]$db2move db_test import


删除表
[db2inst1@localhost mybak]$ db2 connect to db_test
[db2inst1@localhost mybak]$db2 "drop table tb_test01"
[db2inst1@localhost mybak]$db2 "drop table tb_test02"

 

重新导入
[db2inst1@localhost mybak]$cd /tmp/mybak
[db2inst1@localhost mybak]$db2move db_test import
这种方式会将其他的表也导入了


解决办法:编辑如下文件,将不需要导入的表,把相应的记录删除掉
[db2inst1@localhost mybak]$ vi db2move.lst
!"SYSTOOLS"."HMON_ATM_INFO"!tab1.ixf!tab1.msg!
!"SYSTOOLS"."HMON_COLLECTION"!tab2.ixf!tab2.msg!
!"SYSTOOLS"."POLICY"!tab3.ixf!tab3.msg!
!"DB2INST1"."TB_TEST01"!tab4.ixf!tab4.msg!
!"DB2INST1"."TB_TEST02"!tab5.ixf!tab5.msg!

 

posted @ 2024-02-05 10:28  slnngk  阅读(107)  评论(0编辑  收藏  举报