Thursday, 16 April 2020

Script To Set Newname For Datafiles Restore

-- Source Server --

set head off pages 0 feed off echo off verify off
set lines 200
spool rename_datafiles.sql
select 'set newname for datafile ' || file_id || ' to ''/san/data/' ||
substr(file_name,instr(file_name,'/',-1)+1) || ''';'
from dba_data_files ;
spool off

-- on Target Server --
sqlplus "/as sysdba"
set head off pages 0 feed off echo off verify off
set lines 200
spool rename_datafiles.sql
select 'set newname for datafile ' || file# || ' to ''/san/data/' ||
substr(name,instr(name,'/',-1)+1) || ''';'
from v$datafile ;
spool off

No comments:

Post a Comment