## SAMPLEデータベース再作成
$ db2 drop db SAMPLE
$ db2 disconnect al
$ db2sampl -force
## ディレクトリ再作成
rm -fr ./logs ./data
rm -fr ./ikou
## 準備
$ mkdir ikou
$ cd ikou
$ mkdir logs data
## 元データベース(SAMPLE)接続
$ db2 connect to SAMPLE
## DDL取得
$ db2look -d SAMPLE -e -x -o sample.ddl 1> ./logs/db2look.out 2> ./logs/db2look.err
## 確認結果
[db2inst1@localhost logs]$ cat db2look.err
-- No userid was specified, db2look tries to use Environment variable USER
-- USER is: DB2INST1
-- Creating DDL for table(s)
-- Output is sent to file: sample.ddl
-- Binding package automatically ...
-- Bind is successful
-- Binding package automatically ...
-- Bind is successful
正常。バインド成功メッセージだけであればエラーではない
Bind is successful が 2 回出ていて、単なる情報メッセージ(stderr側に出る仕様)
DDL 抽出自体は正常完了している
## 元データベース(SAMPLE)のデータエクスポート
$ db2move SAMPLE export -l $(pwd)/data 1> ./logs/db2move_export.out 2> ./logs/db2move_export.err
## 結果確認
[db2inst1@localhost logs]$ cat db2move_export.err
Binding package automatically ... /home/db2inst1/sqllib/bnd/db2common.bnd ... successful!
Binding package automatically ... /home/db2inst1/sqllib/bnd/db2move.bnd ... successful!
正常。db2move はバインド系メッセージを .err に出すだけで、エクスポートの成否は .out 側に出
## 準備
$ db2 disconnect all
$ db2 connect
## 移行先データベース(SAMPLE2)作成
db2 create db SAMPLE2 using codeset UTF-8 territory JP pagesize 8192 1> ./logs/create_db.out 2> ./logs/create_db.err
## 結果確認
[db2inst1@localhost logs]$ cat create_db.out
DB20000I The CREATE DATABASE command completed successfully.
$ db2 connect to SAMPLE2
## DDL実行
db2 -tvf ./sample.ddl 1> ./logs/apply_ddl.out 2> ./logs/apply_ddl.err
## データインポート
db2move SAMPLE2 import -l $(pwd)/data 1> ./logs/db2move_import.out 2> ./logs/db2move_import.err
## 結果確認
[db2inst1@localhost logs]$ cat db2move_import.err
Binding package automatically ... /home/db2inst1/sqllib/bnd/db2common.bnd ... successful!
Binding package automatically ... /home/db2inst1/sqllib/bnd/db2move.bnd ... successful!
正常。バインド成功メッセージだけであればエラーではない