DB2--迁移数据库--2012-12-02

1、导出书库表空间DDL文件:
F:\>db2look -d gghis -l -o gghis1.txt
-- USER 是: ADMINISTRATOR
-- 输出被发送到文件: gghis1.txt
2、导出源数据库中对象的DDL文件:
F:\>db2look -d gghis -a -e -o gghistable.txt
3、执行DDL文件:
F:\>db2 -tvf 123.txt
4、导出目标数据库表名:
将下列脚本放到一个文本文件中如:文件名.txt;(如:gen_tablelist.txt)

export to table.txt of del modified by nochardel select '"'||ltrim(rtrim(tabschema))||'"'||'.'||'"'||ltrim(trim(tabname))||'"' from syscat.tables where type = 'T' and tabschema='DB2ADMIN' order by tabschema, tabname;

进入命令行,连接目标数据库;执行db2 �Ctvf 文件名.txt
5、DB2MOVE COPY 命令导入数据:
F:\>db2move gghis copy -tf table.txt -u db2admin -p db2 -co target_db test user db2admin using db2 mode load_only
或者 使用 db2move database_name export
db2move database_name load/import
6、检查数据库中表状态:
C:\Program Files\IBM\SQLLIB\BIN>db2 select tabname, colcount, status FROM syscat
.tables where status='C'
TABNAME
COLCOUNT STATUS
--------------------------------------------------------------------------------
 ------------------------------------------------ -------- ------
D_ECIPE_DETAIL
11 C
H_INHOSLEECHDOM_RECORD
31 C
H_LEAVEHOSCHARGE_DETAIL
31 C
H_LEAVEHOSLEECHDOM_RECORD
27 C
T_COUNT_STORAGE
7 C
T_LISTDRUG_STORAGE
10 C
T_MEDIC_STORAGE
11 C
H_INHOSCHARGE_DETAIL
30 C
IF_CITY
7 C
IF_COUNTY
7 C
EXPLAIN_STATEMENT
17 C
EXPLAIN_ARGUMENT
12 C
EXPLAIN_OBJECT
46 C
EXPLAIN_OPERATOR
22 C
EXPLAIN_PREDICATE
17 C
EXPLAIN_STREAM
23 C
EXPLAIN_DIAGNOSTIC
10 C
EXPLAIN_DIAGNOSTIC_DATA

你可能感兴趣的:(it)