AIX环境下实现DB2向Windows 2000迁移(2)

2019-02-15 18:24

SYSCAT.TABLES.TABSCHEMA COPY Wildcard (*) allowed for

EXPORT (not COPY).

-ts Tablespace Names. Filter on EXPORT Comma seperated list, SYSCAT.TABLES.TBSPACE Wildcard (*) allowed.

-tf Fully qualified list of EXPORT one table per line,like: table names in COPY \

\

-aw Allow warnings EXPORT Don't disclude tables that encounter warnings.

-io IMPORT specific actions. IMPORT One of: INSERT, Default is REPLACE_CREATE INSERT_UPDATE, REPLACE, (see docs for limitations CREATE, REPLACE_CREATE

of Import create function)

-lo LOAD specific options. LOAD One of: INSERT,

Default is INSERT REPLACE

-l Path to lobfiles. EXPORT, Comma seperated list, Default is cwd IMPORT, no space characters

LOAD

-u Userid to connect to db. ALL

Default is current user

-p Password to connect to db. ALL

-co COPY specific options. COPY See options listed below.

TARGET_DB [USER [USING ] This mandatory option specifies the target database (and optional

user/passwd) where the schema(s) will be created. (Default

user/passwd are current user/passwd).

MODE

The mode is one of DDL_AND_LOAD (default), DDL_ONLY, or LOAD_ONLY.

SCHEMA_MAP

To rename the schema on the target db. For example, to rename schema

'srcsch1' to 'tgtsch1', and schema 'srcsch2' to 'tgtsch2', use:

\

TABLESPACE_MAP

To override tablespaces on the target db. For example, to recreate all tables that reside in TS1 on the source db, into TS2 on the target db, and all other tablespaces to use the default tablespace

on the target, use: \

NONRECOVERABLE

To override the default Load recoverability action COPY-NO, to

NONRECOVERABLE. OWNER

To override the owner of each new object created on the target db.

Examples:

1) Use db2move to Export all tables: >db2move dbname EXPORT

2) Use db2move to Export all tables, filtering on table-name with 'mytab*'

and table-definer with 'USER1', and lobs in /bigfs/mydir/: >db2move dbname EXPORT -tn mytab* -tc USER1 -l /bigfs/mydir/ 3) Use db2move to Import (recreate and repopulate) all previously exported

tables:

>db2move dbname IMPORT

4) Use db2move to Load (repopulate) all previously exported tables:

>db2move dbname LOAD

5) Use db2move to Load (append) all previously exported tables, where

lobfiles reside in /bigfs/mydir:

>db2move dbname LOAD -lo INSERT -l /bigfs/mydir

6) Use db2move to duplicate schema 'schema1' from source database 'dbsrc'

to target database 'dbtgt':

>db2move dbsrc COPY -sn schema1 -co TARGET_DB dbtgt

USER myuser1 USING mypass1

7) Use db2move to duplicate schema 'schema1' from source database 'dbsrc' to target database 'dbtgt', rename the schema to 'newschema1' on the

target, and map source tablespace 'ts1' to 'ts2' on the target: >db2move dbsrc COPY -sn schema1 -co TARGET_DB dbtgt

USER myuser1 USING mypass1 SCHEMA_MAP ((schema1,newschema1))

TABLESPACE_MAP ((ts1,ts2), SYS_ANY))

在目标系统中,恢复数据库时,由于备份数据库和目标数据库的信息不一致。如:在执行ddl文件时,ddl文件中连接数据库的信息,根据目标系统需要进行相应的修改。如要导入的数据库名与原数据库不同,要

修改creatab.sql中CONNECT 项

如相同则不用更改。

在db2命令窗口中,运行以下命令即可 db2 connect to nc5011 user *** using ***

db2look –tf create.sql

db2move nc5011 load ------db2move nc5011 import

先执行建库脚本,即批量执行create.sql,再导入数据,事先在目标库上建好对象,然后再导入数据。

如果先执行db2move nc5011 import 或者db2move nc5011 load

db2move时系统虽然会自动建表,但是也仅限于表,表上的视图和索引还需要自行创建。 所以需要在导完数据后,用脚本创建索引和视图,以及授权等操作。这样可以防止破坏表的完整性。

在执行上述命令时,需要注意load 和 import的区别.

在使用中,使用import进行数据导入时,当存在外建给时,会校验主表和子表的约束,必须先导入子表,再导

入主表,否则无法导入主表的数据。

如果直接执行load命令,但不再对外键约束进行检查,直接对所有表的数据进行导入。

因此建议在导入数据时,可以优先考虑使用load命令,进行数据的导入。

Db2move在使用export,import或load,进行数据迁移时,可能会发生破坏表完整性约束的情况,需要执行set integrity for immediate checked消除表check pending的状态。

如:

db2 connect to nc5011 user *** using ***

db2 SET INTEGRITY FOR DB2ADMIN.ebank_dfdk_h_r GENERATED COLUMN, FOREIGN KEY,

MATERIALIZED QUERY, CHECK, STAGING FULL ACCESS IMMEDIATE UNCHECKED

如果导入表较多时,可以把命令编辑成批命令,进行批量执行。

如果仍然存在完整性不完整的情况,可以执行如下命令。

db2 reorg table DB2ADMIN.ebank_dfdk_log_h allow read access

批命令执行语法如下:

db2命令行窗口中,连接目标系统中的数据库。 Db2 connect to nc5011 user *** using ***

Alltables.bat Reorgalltables.bat

二、DB2数据库配置文件批量修改说明

由于在搭建NC环境中,需要对新建数据库参数进行修改,而通过GUI进行修改,决不如通过批命令批

量修改效率高。

对于需要修改的参数,编制批命令,直接在db2cmd中进行执行。

update dbm cfg using aslheapsz 256; update dbm cfg using sheapthres 20000 ; update dbm cfg using maxagents 100; update dbm cfg using NUM_POOLAGENTS 30;

update database configuration for nc5011 using DBHEAP 4096; update database configuration for nc5011 using logbufsz 512;

update database configuration for nc5011 using CATALOGCACHE_SZ 1024;

update database configuration for nc5011 using locklist 4096; update database configuration for nc5011 using app_ctl_heap_sz 2048;

update database configuration for nc5011 using sortheap 2048; update database configuration for nc5011 using stmtheap 2048; update database configuration for nc5011 using applheapsz 1024; update database configuration for nc5011 using pckcachesz 10240;

update database configuration for nc5011 using maxlocks 18; update database configuration for nc5011 using NUM_IOCLEANERS 3; update database configuration for nc5011 using NUM_IOSERVERS 3; update database configuration for nc5011 using MAXAPPLS 50; update database configuration for nc5011 using AVG_APPLS 30; update database configuration for nc5011 using logfilsiz 4096; update database configuration for nc5011 using logprimary 20; update database configuration for nc5011 using logsecond 200; update database configuration for nc5011 using MINCOMMIT 2;

三、NC在DB2下批量建立数据库和表空间,提高搭建环境的效率

四、常用问题分析

在使用DB2的过程中,当出现问题时,如果快速定位问题原因,是我们解决问题最有效的方式。DB2自身提供了一套Db2错误代码,以及引用此错误的相关原因的内置信息。可以通过错误相关原因,快速定位

错误类型,及时提供相应的解决方案。

我们可以通过db2 ? SQL(错误代码) 命令查询错误原因。

Eg 4.1NC在db2环境下进行升级客户化的过程中,出现1585错误,导致无法升级成功

解决方案,此错误代码经查询是由于系统临界时表空间定义了4k的页大小,新建系统临界时表空间为16k

页大小,解决了升级问题。

C

ocuments and SettingsAdministrator>db2 ? SQL01585N


AIX环境下实现DB2向Windows 2000迁移(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:120平方的装修合同(12万左右)

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: