db2move dbname action [options]
Action: must be EXPORT, IMPORT, or LOAD.
Options: If not specified, defaults will be used.
** -tc table-creators all creators EXPORT. Wildcard (*) allowed.
** -tn table-names all user tables EXPORT. Wildcard (*) allowed.
** -sn schema-names all schemas EXPORT. Wildcard (*) allowed. UDB sources only.
** -ts tblspace-names all tablespace EXPORT. Wildcard (*) allowed.
** -tf tables from file none EXPORT only.
** -io import-option REPLACE_CREATE IMPORT only.
** -lo load-option INSERT LOAD only.
** -l lobpaths current dir separated by commas. NO BLANKS.
** -u userid logged on userid
** -p password logged on password
** -aw allow-warnings false include tables that encounter
//比如:在合适的目录下,就是把表导出和导入的地方
f:\db2move sample export -sn db2admin
f:\db2move testdb import
Db2move sample export -sn db2admin
Db2 connect to 目标库
Db2move 目标 import
Db2move可以导出索引,但是export不能,因为db2move是用来两个库之间倒数的,所以索引名不会重复。
aliases, views, triggers, user-defined functions等不能通过db2move导出。
第一步:连接数据库
db2 connect to YOURDB
第二步:导出建库表的SQL
db2look -d YOURDB -a -e -x -o creatab.sql
第三步:用db2move将数据备份出来
db2move YOURDB export
第四步:如要导入的数据库名与原数据库不同,要修改creatab.sql中CONNECT 项
vi creatab.sql
第五步:将数据导入新库中
db2move NEWDB load
注:在导入中可能因为种种原因发生中断,会使数据库暂挂
db2 list tablespaces show detail
如:
详细说明:
装入暂挂
总页数 = 1652
可用页数 = 1652
已用页数 = 1652
空闲页数 = 不适用
高水位标记(页) = 不适用
页大小(字节) = 4096
盘区大小(页) = 32
预读取大小(页) = 32
容器数 = 1
状态更改表空间标识 = 2
状态更改对象标识 = 59
db2 select tabname,tableid from syscat.tables where tableid=59
查看是哪张表挂起
表名知道后到db2move.lst(在db2move YOURDB export的目录中)中找到相应的.ixf文件
db2 load from tab11.ixf of ixf terminate into db2admin.xxxxxxxxx
tab11.ixf对应的是xxxxxxxxx表
数据库会恢复正常,可再用db2 list tablespaces show detail查看
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9524210/viewspace-481951/ ,如需转载,请注明出处,否则将追究法律责任。