Some of the most difficult bugs we can find in a database is corrupted data blocks arise.
If we do get this error time will experience an increase in queries or receive ORA-01498 errors.
Oracle has several tools that help us identify and fix corrupted data that are occurring in a database:
a) ANALYZE TABLE table_name VALIDATE STRUCTURE.
b) DBVERIFY.
c) DB_BLOCK_CHECKING parameter.
d) DBMS_REPAIR
ANALYZE TABLE
This sentence is used to validate the structure of objects. If this statement returns an error means that there are bad blocks for that table.
sql>
MiSquema.Mitabla analyze table validate structure;
UTILITY DBVERIFY
is used to validate if there are bad blocks in a particular datafile. You need to tell by
pametro
blocksize block size that we set in the initialization parameter.
>
dbv blocksize = 8192 file = MiDatafile.dbf
DB_BLOCK_CHEKING
DB_BLOCK_CHEKING is an initialization parameter which forces or testing of the blocks each time a tablespace is to make a modification .
DBMS_REPAIR
This package allows to identify and fix the corrupt blocks in tables and indexes. This package is for a number of stored procedures:
CHECK_OBJECT: Detects if there are bad blocks on tables or indices.
FIX_CORRUPT_BLOCKS: Make those bad blocks.
DUMP_ORPHAN_KEYS: indicates those indices which were targeted by corrupt blocks. REBUILT_FREELISTS
SEGMENT_FIX_STATUS SKIP_CORRUPT_BLOCKS: You must use to avoid the ORA-1578 would return after fixing a corrupt block.
ADMIN_TABLES:
We will simulate the identification and fixing of corrupt data within a table: sql >
connect / as sysdba sql
>
MiSquema.Mitabla analyze table validate structure;
OUTPUT: ORA-1498
examine the trace file to identify the file corrupt: OUTPUT ============= data_block_dump nrow = 5 create a table to store recovery information returned by this package. dbms_repair. Dbms_tables (table_name => 'REPAIR_TABLE'
table_type => dbms_reparir.repair_table,
action => dbms_repair.create_action, tablespace => 'USERS' ) table_type => dbms_reparir.repair_table,
Check for bad blocks in the table.
rpr_count int DECLARE, BEGIN dbms_repair. Check_object
(schema_name => 'MiSquema' object_name => 'mytable'
repair_table_name => 'REPAIR_TABLE' corrupt_count => rpr_count) END
rpr_count stored in the number of corrupt blocks found.
The following query displays information about the object involved in the corrupt block.
sql> select object_name
, BLOCK_ID, corrupt_type, marked_corrupt, from REPAIR_TABLE;
Before marking the block as unusable should be a backup of the table.
sql> create table MiTable_back as select * from mytable WHERE
dbms_rowid.rowid_block_number (rowid) = 5
and dbms_rowid.rowid_to_absolute_fno (rowid, 'MiSquema', 'MyTable') = 4
mark the box as unusable: fix_block_count int DECLARE, BEGIN
fix_block_count: = 0;
dbms_repair. fix_corrupt_blocks ( schema_name => 'MiSquema'
object_name => 'mytable', object_type => dbms_repair.table_object, repair_table_name => 'REPAIR_TABLE'
fix_count => fix_block_count) END;
Reference: http://mogukiller.wordpress.com/2008/12/26/reparar-bloques-corruptos/
0 comments:
Post a Comment