Saturday, May 7, 2011

RMAN SET NEWNAME Command


The  SET NEWNAME  command  is  more powerful  and easier  to  use. We can use this command on a specific  tablespace  or  on  all data  files and  temp files. We can  also  change  the names  for  multiple  files in  the  database .This command is very useful in reestore th database .let;s have an example 

Suppose  a   disk  containing  the datafiles  get  corrupt  and  we  have  to restore the datafile  on   different disk . In  this  scenario  we  cannot  use  “restore  database“  command  because  it  wil  restore  the datafile  on  default  location  i.e,  on  corrupt  disk . To overcome  from   this  type  of   scenario’s   we  have  “set newname“  command  to solve this  problem . For  this  we  should  have the valid   rman  backup. 

Here we will restore all the datafile in  'C'  drive which  was  originally on  'D'  drive . Below is an example of   set newname  command .

RMAN> run {
Set  newname  for datafile  1  to  ‘C:\app\SYSTEM.DBF’ ;
Set  newname  for datafile  2  to  ‘C:\app\SYSAUX.DBF’ ;
Set  newname  for datafile  3  to  ‘C:\app\UNDOTBS1.DBF’ ;
Set  newname  for datafile  4  to  ‘C:\app\EXAMPLE.DBF’ ;
Set  newname  for datafile  5  to  ‘C:\app\USERS01.DBF’ ;
Restore database ;
Switch datafile all;
}

SET  command  is  specified  within  a  run  block  to  specify  new  filenames   for  restored  datafiles .  If  we  restore  to  default   location  (that is, we do  not  run  set newname ), then  RMAN  overwrites  file with  the  same  filename. If  we  restore to  a  new  location, then   we   use  SET NEWNAME  commands  to  rename  the  files and  issue  a  SWITCH  command  to  make  the  restored files current. 

If   we  do  not  issue  SWITCH  commands, then   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   we  use  SWITCH  command  in  run  block , then  RMAN  updates   the  datafile  names in  the  control  file to  the  names  of  the  restored  files . 



Enjoy     :-)


2 comments:

Son Alina - Mihaela said...

Hi!

How can I see which datafiles are being used at the moment?

Is it any view in rman catalog that could tell me that?

Thanks in advance,
Alina

i.saygili said...

simple and smooth explanation. thanks a bunch dude!