其中tablespace id即是坏块所在表的表空间ID,object id对应出现坏块的对象ID,可以是表索引或LOB,object type代表损坏对象的类型,0表示表,1表示索引,还有其他的LOB之类的吧,不过很少见,上面可见损坏的是表,所以所以根据信息就可以通过syscat.tables查看损坏的表名称:
db2 select tabschema,tabname from syscat.tables where tableid=72 and tbspaceid=5
TABSCHEMA TABNAME
-----------------------------------------------------------------
WWPP2 WWIDE_FNSHD_PART
然后需要停掉实例直接db2stop force即可
db2dart web /MT /tsi 5 /oi 72
Please enter Table ID or name, tablespace ID, and password:
72,5,********(需IBM 800提供密码)
Mark table phase start.
Set drop-pending (unavailable) state for table objects.
Set state for DAT object 1190 tablespace 8.
Modification for page (obj rel 0, pool rel 982568) of pool ID (5) obj ID (72), written out to disk successfully.
Modification written out successfully.
Mark table phase end.
The requested DB2DART processing has completed successfully!
Complete DB2DART report found in:
/db2_src/db2rilo/sqllib/db2dump/DART0001/web.RPT
这样将表标记为unvaliable了,这时还是可以通过db2look将表结构导出来的,倒出来后直接Drop 掉这个表重建即可。
如果是索引损坏,就可以通过object id和tablespace id在视图syscat.indexes中查到索引的ID号,IID,不同的是标记索引是是个免费功能,参数使用MI,过程大致相当,标记失效后的索引不需要经过drop,根据这个参数设置情况:
Index re-creation time and redo index build (INDEXREC) = SYSTEM (RESTART)
失效的索引会自动重建。
类似的db2dart还有离线导出表中数据的功能,也为免费使用,相对比较简单,通过如下SQL找到相关需要的对象
select rtrim(tabschema)||'.'||tabname,TABLEID||','||TBSPACEID||','||1||','||fpages from syscat.tables where tabschema='EBIZ1' and tabname='TEST'
然后使用ddel即可将怀表中的数据导出格式为DEL的数据文件
db2dart web /DDEL /OI 134 /TSI 6 /PS 1 /NP 100 /V Y /RPT /db2_backup/db2rilo/WEB/db2dart /RPTN WEB_QUOTE
当然整个过程需要交互进行。
至于各个选项代表什么意思,可以通过如下方式查看:
$ db2dart
____________________________________________________________________
_____ D B 2 D A R T _____
Database Analysis Tool
I B M
DB2 6000
The DB2DART Tool is a utility for the analysis of databases,
tablespaces, and tables. DART's primary function is to
examine databases for their architectural correctness, and to
report any encountered errors.
____________________________________________________________________
___________________________________________________________________________
DB2 V9.7 DB2DART HELP
db2dart - Database Analysis Tool
The db2dart command analyses databases, table spaces and tables.
The primary function of this command is to examine databases for
architectural correctness, and to report any encountered errors.
Requirements:
db2dart must be run with no users connected to the database.
Syntax:
db2dart <database name> [action] [options ...]
('db2dart /H' for extended help)