Thursday, November 24, 2011

Restoring Datafiles to Nondefault Locations


If the datafiles have to be restored to some other location due to the serious media failure, then we can use the set of  'set newname' and 'switch' commands within RMAN run{} block

Lets say we want to change the location of datafile 2 and 3 in tablespace 'my_ts tablespace' while the database is closed.

RMAN> connect target /
RMAN> startup mount;
RMAN> run{
2> set newname for datafile 2 to '/ora01/folder/my_ts01.dbf';
3> set newname for datafile 3 to '/ora01/folder/my_ts02.dbf';
4> restore tablespace my_ts;
5> switch datafile all; # Updates repository/controlfile with new datafile location.
6> recover tablespace my_ts;
7> alter database open;
8> }

Use below mentioned example if the database is open

RMAN> run{
2> sql 'alter database datafile 2, 3 offline';
3> set newname for datafile 2 to '/ora01/folder/my_ts01.dbf';
4> set newname for datafile 3 to '/ora01/folder/my_ts02.dbf';
5> restore datafile 2, 3;
5> switch datafile all; # Updates repository with new datafile location.
6> recover datafile 2, 3;
7> sql 'alter database datafile 2, 3 online';
8> }

No comments:

Post a Comment