There are some new feature added to "set newname" command to make it more flexible in 11gR2 .Suppose we are restoring datafiles from the backup, either on the same server or a different one such as staging. If the filesystem (or diskgroup) names are identifical, we won’t have to change anything. But that is hardly ever the case. In staging the f ilesystems may be different, or perhaps we are restoring a production database to an ASM diskgroup different from where it was originally created. In that case we have to let RMAN know the new name of the datafile. The way to do it is using the SET NEWNAME command.
Here is an example, we weill restored datafile 1,2 in ‘D’ drive which previous location was in ‘C’ drive . Here is the rman set newname command .
RMAN> run {
set newname for datafile 1 to ‘D:\oradata\system_01.dbf’;
set newname for datafile 2 to ‘D:\oradata\sysaux_01.dbf’;
restore database;
}
set newname for datafile 2 to ‘D:\oradata\sysaux_01.dbf’;
restore database;
}
Here there are just two datafiles, but what if we have hundreds or even thousands ? It will not only be a herculean task to enter all that information but it will be error-prone as well. Instead of entering each datafile by name, now we can use a single set newname clause for a tablespace. Here is how we can do it:
RMAN> run {
set newname for tablespace examples to 'D:\oradata\examples%b.dbf';
…
… rest of the commands come here …
}
If the tablespace has more than one datafile, they will all be uniquely created. We can use this clause for the entire database as well:
RMAN > run
RMAN > run
{
set newname for database to 'D:\oradata\%b' ;
}
set newname for database to 'D:\oradata\%b' ;
}
The term %b specifies the base filename without the path, e.g. ‘C:\oradata\file1.dbf will be reconsidered as file1.dbf in %b. This is very useful for cases where we are moving the files to a different directory. We can also use it for creating image copies where we will create the backup in a different ocation with the same names as the parent file which will make it easy for identification. Here are some more examples of the placeholders.
%f == is the absolute file number
%U == is a system generated unique name similar to the %U in backup formats
%I == is the Database ID
%N == is the tablespace name
%U == is a system generated unique name similar to the %U in backup formats
%I == is the Database ID
%N == is the tablespace name
Using these placeholders we can use just one SET NEWNAME command for the entire database – making the process not only easy but more accurate as well.
Enjoy : -)
No comments:
Post a Comment