如何使用DBMS_REPAIR检测和修补数据坏块
2008-11-10 12:58:38 来源:WEB开发网DUMP_ORPHAN_KEYS将会显示指向数据坏块中记录的index entries
下列查询显示与坏块相关的index。
SQL> select index_name from dba_indexes
2 where table_name in (select distinct object_name from repair_table);
INDEX_NAME
------------------------------
T1_PK
SQL> @dumpOrphanKeys
SQL> set serveroutput on
SQL>
SQL> declare
2 key_count int;
3 begin
4 key_count := 0;
5 dbms_repair.dump_orphan_keys (
6 schema_name => 'SYSTEM',
7 object_name => 'T1_PK',
8 object_type => dbms_repair.index_object,
9 repair_table_name => 'REPAIR_TABLE',
10 orphan_table_name => 'ORPHAN_KEY_TABLE',
11 key_count => key_count);
12 dbms_output.put_line('orphan key count: ' || to_char(key_count));
13 end;
14 /
orphan key count: 3
PL/SQL procedure successfully completed.
orphan_key_table的结构如下:
SQL> desc orphan_key_table
Name Null? Type
----------------------------------------- -------- ----------------------------
SCHEMA_NAME NOT NULL VARCHAR2(30)
INDEX_NAME NOT NULL VARCHAR2(30)
IPART_NAME VARCHAR2(30)
INDEX_ID NOT NULL NUMBER
TABLE_NAME NOT NULL VARCHAR2(30)
PART_NAME VARCHAR2(30)
TABLE_ID NOT NULL NUMBER
KEYROWID NOT NULL ROWID
KEY NOT NULL ROWID
DUMP_TIMESTAMP NOT NULL DATE
下列查询显示t1_pk index中有3个index entries与坏块有关:
SQL> select index_name, count(*) from orphan_key_table
2 group by index_name;
INDEX_NAME COUNT(*)
------------------------------ ----------
T1_PK 3
更多精彩
赞助商链接