DBMS_REPAIR修復壞塊

xiexingzhi發表於2012-09-11
1、Creating a Repair Table
BEGIN
DBMS_REPAIR.ADMIN_TABLES (
     TABLE_NAME => 'REPAIR_TABLE',
     TABLE_TYPE => dbms_repair.repair_table,
     ACTION     => dbms_repair.create_action,
     TABLESPACE => 'USERS');
END;
/
2、Creating an Orphan Key Table
BEGIN
DBMS_REPAIR.ADMIN_TABLES (
     TABLE_NAME => 'ORPHAN_KEY_TABLE',
     TABLE_TYPE => dbms_repair.orphan_table,
     ACTION     => dbms_repair.create_action,
     TABLESPACE => 'USERS');
END;
/
3、Detecting Corruption
declare
cc number;
begin
dbms_repair.check_object(schema_name => 'OW_PAY_GZ',object_name => 'TB_CM_MSPARAM_HIST',corrupt_count => cc);
dbms_output.put_line(a => to_char(cc));
end;
 /

4、Querying the repair table produces information describing the corruption and suggesting a repair action.
SELECT object_name, relative_file_id, block_id,marked_corrupt, corrupt_description, repair_description,CHECK_TIMESTAMP from repair_table;  

5、Fixing Corrupt Blocks
declare
fix_block_count int;
begin
fix_block_count := 0;
dbms_repair.fix_corrupt_blocks (
schema_name => 'OW_PAY_GZ',
object_name => 'TB_CM_MSPARAM_HIST',
object_type => dbms_repair.table_object,
repair_table_name => 'REPAIR_TABLE',
fix_count => fix_block_count);
dbms_output.put_line('fix blocks count: ' ||
to_char(fix_block_count));
end;
/
6、Finding Index Entries Pointing to Corrupt Data Blocks
SET SERVEROUTPUT ON
DECLARE num_orphans INT;
BEGIN
num_orphans := 0;
DBMS_REPAIR.DUMP_ORPHAN_KEYS (
     SCHEMA_NAME => 'SCOTT',
     OBJECT_NAME => 'PK_DEPT',
     OBJECT_TYPE => dbms_repair.index_object,
     REPAIR_TABLE_NAME => 'REPAIR_TABLE',
     ORPHAN_TABLE_NAME=> 'ORPHAN_KEY_TABLE',
     KEY_COUNT => num_orphans);
DBMS_OUTPUT.PUT_LINE('orphan key count: ' || TO_CHAR(num_orphans));
END;
/
7、Skipping Corrupt Blocks
 exec dbms_repair.skip_corrupt_blocks(schema_name => 'OW_PAY_GZ',object_name => 'TB_CM_MSPARAM_HIST',flags => 1);

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22531473/viewspace-743130/,如需轉載,請註明出處,否則將追究法律責任。

相關文章