生成RMAN rename写法脚本


select  'set newname for datafile ' || x.FILE# || ' to ' ||  
       new_file_Location ||   substr(x.NAME,instr(x.name,'/',-1)+1 ,length(x.name)-instr(x.name,'/',-1))                  
  from v$datafile x,(select &new_loc new_file_Location from dual);



实验一下


SQL> select  'set newname for datafile ' || x.FILE# || ' to ' ||  
  2         new_file_Location ||   substr(x.NAME,instr(x.name,'/',-1)+1 ,length(x.name)-instr(x.name,'/',-1))                  
  3    from v$datafile x,(select &new_loc new_file_Location from dual);
Enter value for new_loc: '/home/oracle/'
old   3:   from v$datafile x,(select &new_loc new_file_Location from dual)
new   3:   from v$datafile x,(select '/home/oracle/' new_file_Location from dual)


'SETNEWNAMEFORDATAFILE'||X.FILE#||'TO'||NEW_FILE_LOCATION||SUBSTR(X.NAME,INSTR(X.NAME,'/',-1)+1,LENGTH(X.NAME)-INSTR(X.NAME,'/',-1))
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
set newname for datafile 1 to /home/oracle/system01.dbf
set newname for datafile 2 to /home/oracle/sysaux01.dbf
set newname for datafile 3 to /home/oracle/undotbs01.dbf
set newname for datafile 4 to /home/oracle/users01.dbf
set newname for datafile 5 to /home/oracle/example01.dbf
 
  

你可能感兴趣的:(ORACLE备份)