Thursday, January 23, 2014

Forgot to give "switch datafile in run " while doing restore

RMAN automates the procedure for restoring files. You do not need to go into the operating system, locate the backup or copy that you want to use, and manually copy files into the appropriate directories. When you issue a RESTORE command, RMAN directs a server session to restore the correct backups and copies to either:
  • The default location, overwriting the files with the same name currently there
  • A new location, which you can specify with the SET NEWNAME command
To restore a datafile, either mount the database or keep it open and take the datafile to be restored offline. When RMAN performs a restore, the RESTORE command creates the restored files as datafile copies and records them in the repository. The following table describes the behavior of the RESTORESET NEWNAME, and SWITCH commands.
Run SET NEWNAME?RESTORE BehaviorRun SWITCH?

No

RMAN restores the files to their current path names and immediately removes the repository records for the datafile copies created during the restore.

N/A

Yes

RMAN restores the files to the path names specified by SET NEWNAME and does not remove the repository records for the datafile copies created during the restore.

If yes, then RMAN updates the datafile names in the control file to the names of the restored files; if no, then RMAN does not update the filenames in the control file and the restored files become datafile copies.
For example, if you restore datafile ?/oradata/trgt/tools01.dbf to its default location, then RMAN restores the file ?/oradata/trgt/tools01.dbf and overwrites any file that it finds with the same filename. If you run a SET NEWNAME command before you restore a file, then RMAN creates a datafile copy with the name that you specify. For example, assume that you run the following commands:
SET NEWNAME FOR DATAFILE '?/oradata/trgt/tools01.dbf' TO '/tmp/tools01.dbf';
RESTORE DATAFILE '?/oradata/trgt/tools01.dbf';

In this case, RMAN creates a datafile copy of ?/oradata/trgt/tools01.dbf named /tmp/tools01.dbf and records it in the repository. To change the name for datafile?/oradata/trgt/tools01.dbf to /tmp/tools01.dbf in the control file, run a SWITCH command so that RMAN considers the restored file as the current database file. For example:

SWITCH DATAFILE '/tmp/tools01.dbf' TO DATAFILECOPY '?/oradata/trgt/tools01.dbf';

No comments:

Post a Comment