生成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);



實驗一下


<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



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章