db2 reorg(轉)
阿新 • • 發佈:2018-07-02
相關 sid 命令 當前 rar 匹配 con data att 當前使用的臨時表空間頁大小和該表的頁大小不符合,需要新建一個頁大小和該表的頁大小符合的系統臨時表空間。
DB2 reorg
RUNSTATS:
db2 connect to rmdb11 user rmadmin using rmadmin
對所有用戶表執行runstats(reorgchk加update參數等同於runstats)
$ db2 reorgchk update statistics on table user
Doing RUNSTATS ....
REORG:
在檢查結果中,所有帶星號的表或分區表、以及索引都需要做reorg重建。
$ db2 reorg table RMADMIN.EXPLAIN_DIAGNOSTIC index SYSIBM.SQL120703164841960 use tempspace1 DB20000I The REORG command completed successfully. $ db2 reorg table RMADMIN.EXPLAIN_DIAGNOSTIC_DATA index RMADMIN.EXP_DIAG_DAT_I1 use tempspace1 DB20000I The REORG command completed successfully. $ db2 reorg table RMADMIN.EXPLAIN_PREDICATE index RMADMIN.PRD_I1 use tempspace1 DB20000I The REORG command completed successfully. $ db2 reorg table RMADMIN.RMSTGGRPCLASS index SYSIBM.SQL120321193908820 use tempspace1 DB20000I The REORG command completed successfully. $ db2 reorg table RMADMIN.RMOBJECTS use tempspace1 SQL2217N The page size of the system temporary table space used by the REORG utility must match the page size of the table space(s)in which the table data resides (including the LONG or LOB column data). The cause is based on the following reason codes "1".
SQL2217N REORG 實用程序使用的系統臨時表空間的頁大小必須與表數據 (包括 LONG 或 LOB 列數據)所在表空間的頁大小相匹配。原因基於下列原因碼 原因碼。 說明 下面是原因碼的列表: 1.原因與表的數據的臨時表空間的選擇相關。 2.原因與表的 LONG 或 LOB 數據的臨時表空間的選擇相關。 如果對 REORG 實用程序顯式地指定了系統臨時表,那麽 REORG 實用程序使用的系統臨時表空間的頁大小必須與表數據(包括 LONG 或 LOB列數據)所在的表空間的頁大小相匹配,否則必須為長數據指定適當的容器。下列其中一項違反了此限制: 表數據所在的表空間的頁大小與指定的系統臨時表空間的頁大小不同。 該表包含 LONG 或 LOB列,這些列的數據駐留在頁大小與系統臨時表空間和表的規則數據的頁大小不同的表空間中,但是,無法為 LONG 或 LOB數據對象找到具有正確頁大小的表空間。 如果未對 REORG 實用程序指定系統臨時表空間或 LONG臨時表空間,那麽該實用程序在內部查找系統臨時表空間。在數據庫中不存在使用與表數據頁大小相同的頁大小的系統臨時表空間,或者該系統臨時表空間此時不可用。 用戶響應 如果數據庫中不存在使用與表數據頁大小相同的頁大小的系統臨時表空間,請創建一個系統臨時表空間,它使用與該表數據的頁大小相匹配的頁大小。如果表數據的頁大小與 LOB 或 LONG 數據的頁大小不同,那麽應確保使用該頁大小的系統臨時表空間也存在。
如果數據庫中存在使用與表數據頁大小相同的頁大小的系統臨時表空間,但是發出命令時該臨時表空間不可用,請在該系統臨時表空間可用時重新發出該命令。
當前使用的臨時表空間頁大小和該表的頁大小不符合,需要新建一個頁大小和該表的頁大小符合的系統臨時表空間。
查看各個表空間的pagesize:
SELECT tbspace, pagesize FROM SYSIBM.SYSTABLESPACES
查看當前bufferpool:
SELECT * FROM SYSCAT.BUFFERPOOLS
新建一個頁大小為32K的bufferpool
$ db2 CREATE BUFFERPOOL temppool32 PAGESIZE 32768 DB20000I The SQL command completed successfully.
新建一個臨時表空間,使用剛才那個bufferpool
$ db2 "create system temporary tablespace tempspace3 pagesize 32K managed by system using (‘/rmdb11data/rminst11/NODE0000/SQL00001/tmpspace3‘) BUFFERPOOL temppool32" DB20000I The SQL command completed successfully.
重新執行reorg:
$ db2 reorg table RMADMIN.RMMIGRATIONTASKS index SYSIBM.SQL120321193909130 use tempspace3
監視表重組:
select substr(tabname, 1, 15) as tab_name, substr(tabschema, 1, 15) as tab_schema, reorg_phase,reorg_max_phase, substr(reorg_type, 1, 20) as reorg_type, reorg_status, reorg_completion, dbpartitionnum from sysibmadm.snaptab_reorg order by dbpartitionnum
或者
db2 GET SNAPSHOT FOR TABLES on DBName
db2 list history reorg all for DBName
db2pd -db DBName -reorgs index
$ db2pd -reorgs -db rmdb11 Database Partition 0 -- Database RMDB11 -- Active -- Up 3 days 21:50:20 -- Date 10/30/2015 14:32:09 Table Reorg Information: Address TbspaceID TableID PartID MasterTbs MasterTab TableName Type IndexID TempSpaceID 0x070000024C0D1528 5 260 n/a n/a n/a EXPLAIN_PREDICATE Offline 1 1 0x070000024C0DEDA8 5 262 n/a n/a n/a EXPLAIN_DIAGNOSTIC Offline 1 1 0x070000024C0E6D28 5 263 n/a n/a n/a EXPLAIN_DIAGNOSTIC Offline 1 1 0x070000024B2C9628 7 5 n/a n/a n/a RMMIGRATIONTASKS Offline 1 13 0x070000024B2A64A8 5 17 n/a n/a n/a RMSTGGRPCLASS Offline 1 1 Table Reorg Stats: Address TableName Start End PhaseStart MaxPhase Phase CurCount MaxCount Status Completion 0x070000024C0D1528 EXPLAIN_PREDICATE 10/30/2015 10:12:38 10/30/2015 10:12:38 10/30/2015 10:12:38 4 IdxRecreat 0 0 Done 0 0x070000024C0DEDA8 EXPLAIN_DIAGNOSTIC 10/30/2015 10:10:58 10/30/2015 10:10:59 10/30/2015 10:10:58 4 IdxRecreat 0 0 Done 0 0x070000024C0E6D28 EXPLAIN_DIAGNOSTIC 10/30/2015 10:12:13 10/30/2015 10:12:13 10/30/2015 10:12:13 4 IdxRecreat 0 0 Done 0 0x070000024B2C9628 RMMIGRATIONTASKS 10/30/2015 12:57:45 n/a 10/30/2015 14:17:16 4 IdxRecreat 202794 576060 Started 0 0x070000024B2A64A8 RMSTGGRPCLASS 10/30/2015 10:13:05 10/30/2015 10:13:05 10/30/2015 10:13:05 4 IdxRecreat 0 0 Done 0
db2 reorg(轉)