VALIDATE DATABASE;

If the output indicates that a data file is inaccessible. You can then run the REPORT SCHEMA command to obtain the tablespace name and file name for the data file.

RMAN> REPORT SCHEMA;

SELECT STATUS FROM V$INSTANCE;

SELECT FILE#, STATUS, ERROR, RECOVER, TABLESPACE_NAME, NAME FROM V$DATAFILE_HEADER WHERE RECOVER = ‘YES’ OR (RECOVER IS NULL AND ERROR IS NOT NULL);

SELECT FILE#, ERROR, ONLINE_STATUS, CHANGE#, TIME FROM V$RECOVER_FILE;

SELECT r.FILE# AS df#, d.NAME AS df_name, t.NAME AS tbsp_name, d.STATUS, r.ERROR, r.CHANGE#, r.TIME FROM V$RECOVER_FILE r, V$DATAFILE d, V$TABLESPACE t WHERE t.TS# = d.TS# AND d.FILE# = r.FILE#;

If you do not have a record of the DBID of your database, then you can find it in the following places without opening your database:

■The DBID is used in forming the file name for the control file autobackup. Locate this file

By default, the format of the autobackup file for all configured devices is the substitution variable %F in the FORMAT clause. This variable format translates into c-IIIIIIIIII-YYYYMMDD-QQ, with the placeholders defined as follows:
IIIIIIIIII stands for the DBID.
YYYYMMDD is a time stamp of the day the backup is generated.
QQ is the hexadecimal sequence that starts with 00 and has a maximum of FF.

■If you have any text files that preserve the output from an RMAN session, then the DBID is displayed by the RMAN client when it starts up and connects to your database.

RESTORE DATABASE PREVIEW;

RESTORE ARCHIVELOG FROM TIME ‘SYSDATE-7’ PREVIEW;

RESTORE DATABASE PREVIEW SUMMARY;

RESTORE ARCHIVELOG ALL PREVIEW RECALL;

RUN
{
SET ARCHIVELOG DESTINATION TO ‘/oracle/temp_restore’;
RESTORE ARCHIVELOG ALL;
}

RUN
{
SET ARCHIVELOG DESTINATION TO ‘/oracle/temp_restore’;
RESTORE DATABASE;
RECOVER DATABASE; # restores and recovers logs automatically
}

RUN
{
# Set a new location for logs 1 through 100.
SET ARCHIVELOG DESTINATION TO ‘/fs1/tmp’;
RESTORE ARCHIVELOG FROM SEQUENCE 1 UNTIL SEQUENCE 100;
# Set a new location for logs 101 through 200.
SET ARCHIVELOG DESTINATION TO ‘/fs2/tmp’;
RESTORE ARCHIVELOG FROM SEQUENCE 101 UNTIL SEQUENCE 200;
# Set a new location for logs 201 through 300.
SET ARCHIVELOG DESTINATION TO ‘/fs3/tmp’;
RESTORE ARCHIVELOG FROM SEQUENCE 201 UNTIL SEQUENCE 300;
# restore and recover data files as needed
.
.
}

 

RUN
{
SET NEWNAME FOR DATAFILE 2 TO ‘/disk2/df2.dbf’;
SET NEWNAME FOR DATAFILE 3 TO ‘/disk2/df3.dbf’;
SET NEWNAME FOR DATAFILE 4 TO ‘/disk2/df4.dbf’;
RESTORE DATABASE;
SWITCH DATAFILE ALL;
RECOVER DATABASE;
}

To restore and recover a tablespace:

ALTER TABLESPACE users OFFLINE IMMEDIATE;

RESTORE TABLESPACE users;

RECOVER TABLESPACE users;

OR

RUN
{
# specify the new location for each datafile
SET NEWNAME FOR DATAFILE ‘/disk1/oracle/dbs/users01.f’ TO ‘/disk2/users01.f’;
SET NEWNAME FOR DATAFILE ‘/disk1/oracle/dbs/users02.f’ TO ‘/disk2/users02.f’;
SET NEWNAME FOR DATAFILE ‘/disk1/oracle/dbs/users03.f’ TO ‘/disk2/users03.f’;
RESTORE TABLESPACE users;
SWITCH DATAFILE ALL; # update control file with new file names
RECOVER TABLESPACE users;
}

ALTER TABLESPACE users ONLINE;

Performing Complete Recovery After Switching to a Copy

Switching to a Data File Copy

ALTER DATABASE DATAFILE 4 OFFLINE;
SWITCH DATAFILE 4 TO COPY;
RECOVER DATAFILE 4;
ALTER DATABASE DATAFILE 4 ONLINE;

To switch to a database copy and perform recovery:

SWITCH DATABASE TO COPY;
RECOVER DATABASE;
ALTER DATABASE OPEN;