db2 reorg(转)

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         

猜你喜欢

转载自www.cnblogs.com/dahaoran/p/9254430.html