首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 數據庫知識 >  >> DB2 資料庫 >> DB2 教學

db2move 資料遷移與 Load Pending 解鎖實戰指南

     編輯:DB2 教學

標準遷移流程

  1. db2 connect to YOURDB
  2. db2look -d YOURDB -a -e -x -o creatab.sql 匯出 DDL(含授權、索引、觸發器等)
  3. db2move YOURDB export 匯出資料(產生 *.ixf、*.msg、db2move.lst)
  4. 若目標資料庫名不同,編輯 creatab.sql 修改 CONNECT 陳述式
  5. db2move NEWDB load 載入資料

Load 中斷導致表空間 Load Pending 處理

1. 確認受影響表空間與表

db2 list tablespaces show detail
-- 找到 State = "Load Pending" 的表空間,記下 "State change object id" (TABLEID)

db2 "select tabname, tableid from syscat.tables where tableid = <TABLEID>"
-- 得到表名

2. 定位對應 IXF 檔案

查看 db2move.lst,找到該表對應的 tabxxx.ixf。

3. 執行 Load Terminate 解鎖

db2 load from tabxxx.ixf of ixf terminate into <schema>.<tablename>

4. 驗證恢復

db2 list tablespaces show detail
-- 表空間狀態應恢復正常 (Normal)

常見問題與技巧

  • db2move load 預設 REPLACE 模式,目標表必須存在且結構一致。
  • 大量表遷移建議分批,避免單一交易過大導致日誌滿。
  • db2look -x 匯出授權,-e 匯出觸發器/程序,-a 所有 schema。
  • 跨版本遷移參考 ID 98721:高版本 db2look 可提取低版本物件完整 DDL。
  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved