Skip Headers
Oracle® Database Backup and Recovery User's Guide
11g Release 2 (11.2)

Part Number E10642-03
Go to Documentation Home
Go to Book List
Book List
Go to Table of Contents
Go to Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Go to next page
View PDF

19 Performing Block Media Recovery

This chapter explains how to restore and recover individual data blocks within a datafile. This chapter contains the following topics:

See Also:

Overview of Block Media Recovery

This section explains the purpose and basic concepts of block media recovery.

Purpose of Block Media Recovery

You can use block media recovery to recover one or more corrupt data blocks within a datafile. Block media recovery provides the following advantages over datafile media recovery:

  • Lowers the Mean Time To Recover (MTTR) because only blocks needing recovery are restored and recovered

  • Enables affected datafiles to remain online during recovery

    Without block media recovery, if even a single block is corrupt, then you must take the datafile offline and restore a backup of the datafile. You must apply all redo generated for the datafile after the backup was created. The entire file is unavailable until media recovery completes. With block media recovery, only the blocks actually being recovered are unavailable during the recovery.

Block media recovery is most useful for physical corruption problems that involve a small, well-known number of blocks. Block-level data loss usually results from intermittent, random I/O errors that do not cause widespread data loss, as well as memory corruptions that get written to disk. Block media recovery is not intended for cases where the extent of data loss or corruption is unknown and the entire datafile requires recovery. In such cases, datafile media recovery is the best solution.

Basic Concepts of Block Media Recovery

In most cases, the database marks a block as media corrupt and then writes it to disk when the corruption is first encountered. No subsequent read of the block will be successful until the block is recovered. You can only perform block recovery on blocks that are marked corrupt or fail a corruption check.

If the database on which the corruption occurs is associated with a real-time query physical standby database, then the database automatically attempts to perform block media recovery. The primary database searches for good copies of blocks on the standby database and, if found, repairs the blocks with no impact to the query that encountered the corrupt block. Only if the database is unable to repair the corruption is the Oracle physical block corruption message (ORA-1578) displayed.

Whenever block corruption has been automatically detected, you can perform block media recovery manually with the RECOVER ... BLOCK command. By default, RMAN first searches for good blocks in the real-time query physical standby database, then flashback logs and then blocks in full or level 0 incremental backups.


For auto-block media recovery to work, the physical standby database must be in real-time query mode. An Active Data Guard license is required.

If a corrupt data block is discovered on a real-time query physical standby database, the server attempts to repair the corruption by obtaining a copy of the block from the primary database. The repair is performed in the background enabling subsequent queries to succeed if the repair is successful. Automatic block repair is attempted if the following database initialization parameters are configured on the the standby database as described:

  • The LOG_ARCHIVE_CONFIG parameter is configured with a DG_CONFIG list and a LOG_ARCHIVE_DEST_n parameter is configured for the primary database with the DB_UNIQUE_NAME attribute


  • The FAL_SERVER parameter is configured and its value contains an Oracle Net service name for the primary database

See Also:

Identification of Corrupt Blocks

The V$DATABASE_BLOCK_CORRUPTION view displays blocks marked corrupt by database components such as RMAN, ANALYZE, dbv, and SQL queries. The following types of corruption result in rows added to this view:

  • Physical corruption (sometimes called media corruption)

    The database does not recognize the block: the checksum is invalid, the block contains all zeros, or the block header is fractured.

    Physical corruption checking is enabled by default. You can turn off checksum checking by specifying the NOCHECKSUM option of the BACKUP command, but other physical consistency checks, such as checks of the block headers and footers, cannot be disabled.

  • Logical corruption

    The block has a valid checksum, the header and footer match, and so on, but the contents are logically inconsistent. Block media recovery may not be able to repair all logical block corruptions. In these cases, alternate recovery methods, such as tablespace point-in-time recovery, or dropping and recreating the affected objects, may repair the corruption.

    Logical corruption checking is disabled by default. You can turn it on by specifying the CHECK LOGICAL option of the BACKUP, RESTORE, RECOVER, and VALIDATE commands.

The database can detect some corruptions by validating relationships between blocks and segments, but cannot detect them by a check of an individual block. The V$DATABASE_BLOCK_CORRUPTION view does not record this type of corruption.

Missing Redo During Block Recovery

Like datafile media recovery, block media recovery cannot generally survive a missing or inaccessible archived log, although it will attempt restore failover when looking for usable copies of archived redo log files, as described in "Restore Failover". Also, block media recovery cannot survive physical redo corruptions that result in checksum failure. However, block media recovery can survive gaps in the redo stream if the missing or corrupt redo records do not affect the blocks being recovered. Whereas datafile recovery requires an unbroken series of redo changes from the beginning of recovery to the end, block media recovery only requires an unbroken set of redo changes for the blocks being recovered.


Each block is recovered independently during block media recovery, so recovery may be successful for a subset of blocks.

When RMAN first detects missing or corrupt redo records during block media recovery, it does not immediately signal an error because the block undergoing recovery may become a newed block later in the redo stream. When a block is newed all previous redo for that block becomes irrelevant because the redo applies to an old incarnation of the block. For example, the database can new a block when users drop or truncate a table and then use the block for other data.

Assume that media recovery is performed on block 13 as depicted in the following figure.

Figure 19-1 Performing RMAN Media Recovery

Diagram of example block recovery
Description of "Figure 19-1 Performing RMAN Media Recovery"

After block recovery begins, RMAN discovers that change 120 is missing from the redo stream, either because the log block is corrupt or because the log cannot be found. RMAN continues recovery in the hope that block 13 will be newed later in the redo stream. Assume that in change 140 a user drops the table employees stored in block 13, allocates a new table in this block, and inserts data into the new table. At this point, the database formats block 13 as a new block. Recovery can now proceed with this block even though some redo preceding the newing operation was missing.

Prerequisites for Block Media Recovery

The following prerequisites apply to the RECOVER ... BLOCK command:

Recovering Individual Blocks

Typically, block corruption is reported in the following locations:

For example, you may discover the following messages in a user trace file:

ORA-01578: ORACLE data block corrupted (file # 7, block # 3)
ORA-01110: data file 7: '/oracle/oradata/trgt/tools01.dbf'
ORA-01578: ORACLE data block corrupted (file # 2, block # 235)
ORA-01110: data file 2: '/oracle/oradata/trgt/undotbs01.dbf'

In the following procedure, you identify the blocks that require recovery and then use any available backup to perform the restore and recovery of these blocks.

To recover specific data blocks:

  1. Obtain the datafile numbers and block numbers of the corrupted blocks.

    The easiest way to locate trace files and the alert log is to connect SQL*Plus to the target database and execute the following query:

  2. Start RMAN and connect to the target database, which must be mounted or open.

  3. Run the SHOW ALL command to make sure that the appropriate channels are preconfigured.

  4. Run the RECOVER ... BLOCK command at the RMAN prompt, specifying the file and block numbers for the corrupted blocks.

    The following example recovers two blocks.

      DATAFILE 8 BLOCK 13 
      DATAFILE 2 BLOCK 19;

    You can also specify various options to control RMAN behavior. The following example indicates that only backups with tag mondayam will be used when searching for blocks. You could use the FROM BACKUPSET option to restrict the type of backup that RMAN searches, or EXCLUDE FLASHBACK LOG to restrict RMAN from searching the flashback logs.

      DATAFILE 8 BLOCK 13 
      DATAFILE 2 BLOCK 199
      FROM TAG mondayam;


In this scenario, RMAN automatically recovers all blocks listed in the V$DATABASE_BLOCK_CORRUPTION view.

To recover all blocks logged in V$DATABASE_BLOCK_CORRUPTION:

  1. Start SQL*Plus and connect to the target database.

  2. Query V$DATABASE_BLOCK_CORRUPTION to determine whether corrupt blocks exist. For example, execute the following statement:

  3. Start RMAN and connect to the target database.

  4. Recover all blocks marked corrupt in V$DATABASE_BLOCK_CORRUPTION.

    The following command repairs all physically corrupted blocks recorded in the view:


    After the blocks are recovered, the database removes them from V$DATABASE_BLOCK_CORRUPTION.

See Also:

Oracle Database Backup and Recovery Reference to learn about the RECOVER ... BLOCK command