Skip to Main Content
  • Questions
  • Is it possible to "format" an unused corrupt Oracle block?

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Mark.

Asked: January 12, 2016 - 1:02 pm UTC

Last updated: January 13, 2016 - 4:45 am UTC

Version: 12.1.0.2

Viewed 1000+ times

You Asked

Hi Tom,
in all Oracle documentation and online resources I am told that I'm lucky if I have a corrupt Oracle block which isn't used by any segment, I should simply ignore it. If the Oracle block will be reused, it is initialized and the corruption disappears.
So far, so good. However, when regularly checking Oracle databases for consistency, such unused corrupt Oracle blocks are annoying. Either there is a problem with a segment and I have to deal with it, or the database consistency check should report that everything is fine. I hate false positive messages. I have been looking for years for a solution, but so far I haven't found any.
DBMS_REPAIR.FIX_CORRUPT_BLOCKS sounds good, but it only works on segments, not on freespace.
Is there any Oracle procedure to format an unused Oracle block? Or as a workaround is it possible to create a segment which allocates a certain block in a certain datafile? (ALTER TABLE ... ALLOCATE EXTENT isn't helpful.)
Regards,
Mark

and Connor said...

Rman should be able to do it ... eg

SQL> create tablespace DEMO datafile 'C:\ORACLE\ORADATA\NP12\DEMO01.DBF' size 10m;

Tablespace created.


I then took a backup of the datafile with rman, then took the tablespace offline and hex-edited a block to "corrupt" it. Then did this:


RMAN> backup check logical validate datafile 5;

Starting backup at 13-JAN-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=128 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=C:\ORACLE\ORADATA\NP12\DEMO01.DBF
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
5    FAILED 0              1152         1280            7373677
  File Name: C:\ORACLE\ORADATA\NP12\DEMO01.DBF
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              0
  Index      0              0
  Other      1              128

validate found one or more corrupt blocks
See trace file C:\ORACLE\diag\rdbms\np12\np12\trace\np12_ora_4256.trc for details
Finished backup at 13-JAN-16


The trace file said block 300 is corrupted... so


RMAN> RECOVER DATAFILE 5 BLOCK 300 ;

Starting recover at 13-JAN-16
using channel ORA_DISK_1

channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00005
channel ORA_DISK_1: reading from backup piece C:\ORACLE\PRODUCT\12.1.0.2\DATABASE\02QR92VF_1_1
channel ORA_DISK_1: piece handle=C:\ORACLE\PRODUCT\12.1.0.2\DATABASE\02QR92VF_1_1 tag=TAG20160113T123910
channel ORA_DISK_1: restored block(s) from backup piece 1
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:01

starting media recovery
media recovery complete, elapsed time: 00:00:01

Finished recover at 13-JAN-16

RMAN> backup check logical validate datafile 5;

Starting backup at 13-JAN-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=C:\ORACLE\ORADATA\NP12\DEMO01.DBF
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
5    OK     0              1152         1281            7373677
  File Name: C:\ORACLE\ORADATA\NP12\DEMO01.DBF
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              0
  Index      0              0
  Other      0              128

Finished backup at 13-JAN-16

RMAN>




Is this answer out of date? If it is, please let us know via a Comment

More to Explore

Backup/Recovery

Check out the complete guide to all of the Backup & Recovery techniques in the Oracle Database.