mardi 30 août 2011

Oracle 11g : How to know which file to recover

Using SQLplus
Connect to the database and use the following sql instruction :
SQL>select * from v$recover_file;
     FILE# ONLINE  ONLINE_ ERROR                                                                CHANGE# TIME
---------- ------- ------- ----------------------------------------------------------------- ---------- ---------
        44 ONLINE  ONLINE  FILE NOT FOUND                                                             0
As you can see the file with id 44 is missing.

To retrieve the name of the datafile you can write :
SQL>select file#, name from v$datafile join v$recovery_file using( file#);

Using RMAN
To validate the structure of the database.
$>rman target /
RMAN>validate database;
If you want to validate also logical block failure :
$>rman target /
RMAN>validate database CHECK LOGICAL;

To list all database failure that need to be restored or recovered:
$>rman target /
RMAN>list failure all;

To ask an advise from the data recovery advisor :
$>rman target /
RMAN>advise failure;

To ask rman to recover all failure that could be repaired automatically :
$>rman target /
RMAN>repair failure;
The 'repair failure' command need to be executed after the 'advise failure' command because 'advise failure' registers all problems in the Automatic Diagnostic Repository.