rem  Outputs "alter database" commands to rename files from one DG to another
rem
rem  Intended to be used in a command like :
rem    sqlplus -S / as sysdba @renamefile OLDDGNAME NEWDGNAME | sqlplus / as sysdba
rem
rem  A spool file could also be used to output the results to a .sql file and then
rem  execute that file

SET LINESIZE 32767
SET PAGESIZE 0
SET VERIFY OFF
SET UNDERLINE OFF
SET HEADING OFF

select 'alter database rename file '''||name||''' to ''+&2'||substr(name,instr(name,'/',1,1))||''';' from V$DATAFILE where name like '+&1/%';
select 'alter database rename file '''||member||''' to ''+&2'||substr(member,instr(member,'/',1,1))||''';' from V$LOGFILE where member like '+&1/%';
select 'alter database rename file '''||name||''' to ''+&2'||substr(name,instr(name,'/',1,1))||''';' from V$TEMPFILE where name like '+&1/%';

exit;

