Block-level corruption is rare and is usually caused by some sort of I/O error. It can rescue you from having to do a complete restore of a data file with recovery.
However, if you do have an isolated corrupt block within a large data file, it is nice to have the option of performing a block-level recovery.
Block-level recovery is useful when a small number of blocks are corrupt within a data file. Block recovery is not appropriate if the entire data file needs media recovery.
I have actually had to use this a few times; however, now with ASM this type of issue has been significantly reduced.
RMAN will automatically detect corrupt blocks whenever a BACKUP, VALIDATE, or BACKUP VALIDATE command is run. Details on corrupt blocks can be viewed in the V$DATABASE_BLOCK_CORRUPTION view. In the following example, the regular backup job has reported a corrupt block in the output:
ORA-19566: exceeded limit of 0 corrupt blocks for file…
Querying the V$DATABASE_BLOCK_CORRUPTION view indicates which file contains corruption:
SQL> select * from v$database_block_corruption;
Your database can be either mounted or open when performing block-level recovery.
You do not have to take offline the data file being recovered. You can instruct RMAN to recover all blocks reported in V$DATABASE_BLOCK_CORRUPTION, as shown here:
RMAN> recover corruption list;
If successful, the following message is displayed:
media recovery complete…
Another way to recover the block is to specify the data file and block number, like so:
RMAN> recover datafile 4 block 20;
It is preferable to use the RECOVER CORRUPTION LIST syntax because it will clear out any blocks recovered from the V$DATABASE_BLOCK_CORRUPTION view.
RMAN cannot perform block-level recovery on block 1 (data file header) of the data file.
Block-level media recovery allows you to keep your database available and also reduces the mean time to recovery, as only the corrupt blocks are offline during the recovery.
Your database must be in archivelog mode for performing block-level recoveries. RMAN can restore the block from the flashback logs (if available).
If the flashback logs are not available, then RMAN will attempt to restore the block from a full backup, a level 0 backup, or an image copy backup generated by the BACKUP AS COPY command. After the block has been restored, any required archivelogs must be available to recover the block.
RMAN cannot perform block media recovery using incremental level 1 (or higher) backups.