-- SQL to execute on source database to generate commands to mount the snapshot clone
set pagesize 999
set linesize 255
select
'alter system set db_name='||name||' scope=spfile;' "-- SET DB_NAME"
from v$database;
select
'alter system set control_files ='||chr(10)||chr(39)|| -- value||
regexp_replace(
regexp_replace(
regexp_replace(value, '\+SWINGDATA', '+CLONESWINGDATA' ) -- replace SWINGDATA with CLONESWINGDATA
,'\+FRA', '+CLONEFRA' ) -- replace FRA with CLONEFRA
, ', ', chr(39)||','||chr(10)||chr(39), 2)|| -- replace the comma-space with a tick,LF,comma,tick
chr(39)||chr(10)||' scope=spfile;' "-- RENAME_CONTROLFILES"
from v$parameter
where name = 'control_files';
select
'alter database rename file '||chr(39)||name||chr(39)||' to '||chr(39)||
regexp_replace(name, '\+SWINGDATA', '+CLONESWINGDATA' )||
chr(39)||';' "-- RENAME_DATAFILES"
from v$datafile;
select
'alter database rename file '||chr(39)||member||chr(39)||' to '||chr(39)||
regexp_replace(member, '\+FRA', '+CLONEFRA' )||
chr(39)||';' "-- RENAME_LOGFILES"
from v$logfile;