我正在寻找使用Toad制作DB2数据库副本的解决方案。
我尝试过这样的db2move
命令:
db2move sample COPY -sn BASESAT -co target_db schema_map "((BASESAT,BASESAT4))" -u SATURNE
BASESAT
是我的数据库,BASESAT4
是我要创建的副本
我收到此错误:
当我尝试命令模式时。我得到了这个
答案 0 :(得分:0)
也许这可以帮到你。
创建示例数据库;
user@host:/home/db2inst1:>db2 "create db sampledb"
DB20000I The CREATE DATABASE command completed successfully.
user@host:/home/db2inst1:>db2 connect to sampledb
Database Connection Information
Database server = DB2
SQL authorization ID = DB2INST1
Local database alias = SAMPLEDB
样本表;
user@host:/home/db2inst1:>db2 "CREATE TABLE SAMPLETABLE (COL1 CHAR(6) NOT NULL, COL2 VARCHAR(24) NOT NULL)"
DB20000I The SQL command completed successfully.
插入虚拟行;
user@host:/home/db2inst1:>db2 "insert into SAMPLETABLE VALUES ('test1','test2')"
DB20000I The SQL command completed successfully.
这是出口;
user@host:/home/db2inst1:>mkdir data
user@host:/home/db2inst1:>cd data/
user@host:/home/db2inst1/data:>db2move sampledb export
Application code page not determined, using ANSI codepage 819
***** DB2MOVE *****
Action: EXPORT
Start time: Mon Jul 18 17:49:49 2016
Connecting to database SAMPLEDB ... successful! Server : DB2 Common Server V10.5.7
EXPORT: 147 rows from table "SYSTOOLS"."HMON_ATM_INFO"
EXPORT: 0 rows from table "SYSTOOLS"."HMON_COLLECTION"
EXPORT: 5 rows from table "SYSTOOLS"."POLICY"
EXPORT: 1 rows from table "DB2INST1"."SAMPLETABLE"
Disconnecting from database ... successful!
End time: Mon Jul 18 17:49:49 2016
生成ddls。
user@host:/home/db2inst1/data:>db2look -d sampledb -e -a -o db2look.sql
-- Generate statistics for all creators
-- Creating DDL for table(s)
-- Output is sent to file: db2look.sql
-- Binding package automatically ...
-- Bind is successful
-- Binding package automatically ...
-- Bind is successful
user@host:/home/db2inst1/data:>db2 terminate
DB20000I The TERMINATE command completed successfully.
这是第二个数据库。
user@host:/home/db2inst1/data:>db2 "create db copydb"
DB20000I The CREATE DATABASE command completed successfully.
user@host:/home/db2inst1/data:>db2 "connect to copydb"
Database Connection Information
Database server = DB2
SQL authorization ID = DB2INST1
Local database alias = COPYDB
在db2look中更改数据库名称,如下所示
CONNECT TO COPYDB;
user@host:/home/db2inst1/data:>db2 -tvf db2look.sql
CONNECT TO COPYDB
Database Connection Information
Database server = DB2
SQL authorization ID = DB2INST1
Local database alias = COPYDB
CREATE SCHEMA "DB2INST1"
DB20000I The SQL command completed successfully.
CREATE TABLE "DB2INST1"."SAMPLETABLE" ( "COL1" CHAR(6 OCTETS) NOT NULL , "COL2" VARCHAR(24 OCTETS) NOT NULL ) IN "USERSPACE1" ORGANIZE BY ROW
DB20000I The SQL command completed successfully.
COMMIT WORK
DB20000I The SQL command completed successfully.
CONNECT RESET
DB20000I The SQL command completed successfully.
TERMINATE
DB20000I The TERMINATE command completed successfully.
您也可以使用导入而不是加载。
user@host:/home/db2inst1/data:>db2move copydb load
Application code page not determined, using ANSI codepage 819
***** DB2MOVE *****
Action: LOAD
Start time: Mon Jul 18 17:57:41 2016
Connecting to database COPYDB ... successful! Server : DB2 Common Server V10.5.7
Binding package automatically ... /home/db2inst1/sqllib/bnd/db2common.bnd ... successful!
Binding package automatically ... /home/db2inst1/sqllib/bnd/db2move.bnd ... successful!
* LOAD: table "SYSTOOLS"."HMON_ATM_INFO"
*** ERROR -3304. Check message file tab1.msg!
*** SQLCODE: -3304 - SQLSTATE:
*** SQL3304N The table does not exist.
* LOAD: table "SYSTOOLS"."HMON_COLLECTION"
*** ERROR -3304. Check message file tab2.msg!
*** SQLCODE: -3304 - SQLSTATE:
*** SQL3304N The table does not exist.
* LOAD: table "SYSTOOLS"."POLICY"
*** ERROR -3304. Check message file tab3.msg!
*** SQLCODE: -3304 - SQLSTATE:
*** SQL3304N The table does not exist.
* LOAD: table "DB2INST1"."SAMPLETABLE"
-Rows read: 1
-Loaded: 1
-Rejected: 0
-Deleted: 0
-Committed: 1
**Error occured -1
Disconnecting from database ... successful!
End time: Mon Jul 18 17:57:43 2016
user@host:/home/db2inst1/data:>db2 "connect to copydb"
Database Connection Information
Database server = DB2
SQL authorization ID = DB2INST1
Local database alias = COPYDB
user@host:/home/db2inst1/data:>db2 "select * from SAMPLETABLE"
COL1 COL2
------ ------------------------
test1 test2
1 record(s) selected.
答案 1 :(得分:0)
感谢您的帮助,我得到了解决方案。 如果其他人遇到同样的问题,请执行以下步骤: 1 - 创建要复制的数据库(在我的例子中为BASESAT2) 2在命令模式下使用db2move,如下所示: db2move dbname COPY -sn SCHEMA_OF_YOUR_DBname -co TARGET_DB dbname_copy USER user_name USING password
这是截图。