您的位置:首页 > 其它

生成RMAN rename写法脚本

2016-06-26 19:02 309 查看
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);


实验一下

<pre code_snippet_id="1730831" snippet_file_name="blog_20160626_1_5099860" name="code" class="sql">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


                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: