Corruption was CheckSum and was not fixed by this process...
----------- How to find the tables with the problem -----
Where corrupt block is in File_ID=10 and Block # 270456
SELECT
owner
, segment_name
, tablespace_name
FROM
dba_extents
WHERE
FILE_ID=10
AND 270456 BETWEEN BLOCK_ID AND BLOCK_ID+BLOCKS;
-------------------------------------
Setup a Table Space for DBMS_REPAIR tables:
CREATE SMALLFILE TABLESPACE "DBMS_REPAIR_TBL"
DATAFILE
'Repair1.dbf' SIZE 200M AUTOEXTEND ON NEXT 200M MAXSIZE 5G,
'Repair2.dbf' SIZE 200M AUTOEXTEND ON NEXT 200M MAXSIZE 5G,
'Repair3.dbf' SIZE 200M AUTOEXTEND ON NEXT 200M MAXSIZE 5G,
'Repair4.dbf' SIZE 200M AUTOEXTEND ON NEXT 200M MAXSIZE 5G
NOLOGGING
DEFAULT NOCOMPRESS
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
SEGMENT SPACE MANAGEMENT AUTO;
Source for the below is:
http://www.dba-oracle.com/concepts/dbms_repair.htm
---------- Create Two Tables
begin
dbms_repair.admin_tables(
table_name => 'REPAIR_TABLE',
table_type => dbms_repair.repair_table,
action => dbms_repair.create_action,
tablespace => 'DBMS_REPAIR_TBL' );
end;
/
begin
dbms_repair.admin_tables(
table_name => 'ORPHAN_TABLE',
table_type => dbms_repair.orphan_table,
action => dbms_repair.create_action,
tablespace => 'DBMS_REPAIR_TBL'
);
end;
---------------- Run Check Table
set serveroutput on
declare corr_count binary_integer;
begin
corr_count := 0;
dbms_repair.CHECK_OBJECT (
schema_name => 'HYP_CCC',
object_name => 'ENTITY_DAY_FACT',
partition_name => null,
object_type => dbms_repair.table_object,
repair_table_name => 'REPAIR_TABLE',
flags => null,
relative_fno => null,
block_start => null,
block_end => null,
corrupt_count => corr_count
);
dbms_output.put_line(to_char(corr_count));
end;
/
--- IF ERRORS found run Fix Table OR Fix Index
SET SERVEROUTPUT ON
DECLARE fix_count INT;
BEGIN
Fix_count := 0;
DBMS_REPAIR.FIX_CORRUPT_BLOCKS (
SCHEMA_NAME => 'HYP_CCC',
OBJECT_NAME=> 'ENTITY_DAY_FACT',
OBJECT_TYPE => dbms_repair.table_object,
REPAIR_TABLE_NAME => 'REPAIR_TABLE',
FIX_COUNT=> fix_count);
DBMS_OUTPUT.PUT_LINE('Fix count = ' || TO_CHAR(fix_count));
END;
/
---
SET SERVEROUTPUT ON
DECLARE key_count INT;
BEGIN
key_count := 0;
DBMS_REPAIR.DUMP_ORPHAN_KEYS (
SCHEMA_NAME => 'HYP_CCC',
OBJECT_NAME => 'INDEX_NAME_HERE',
OBJECT_TYPE => dbms_repair.index_object,
REPAIR_TABLE_NAME => 'REPAIR_TABLE',
ORPHAN_TABLE_NAME=> 'ORPHAN_KEY_TABLE',
KEY_COUNT => key_count);
DBMS_OUTPUT.PUT_LINE('Orphan key count: ' || TO_CHAR(key_count));
END;
/
----------