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/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/22531473/viewspace-743130/
本文详细介绍了数据库中使用DBMS_REPAIR工具进行表和索引修复的步骤,包括创建修复表和孤儿键表、检测和查询损坏块、修复损坏块、查找指向损坏数据块的索引条目以及跳过损坏块等操作。
596

被折叠的 条评论
为什么被折叠?



