Set serveroutput on
set head off
set pages 0
set lines 300
set feed onregis
spool clone_db_newname_data.lst

declare
dummy varchar2(1);
cursor c1 is
select file_id, file_name, bytes
from dba_data_files
order by file_id;

v_file_name varchar2(200);

rec c1%rowtype;
i integer;
j integer;
k integer;
begin
i := 1;
k := 1;
j := 1;
dbms_output.put_line('run');
dbms_output.put_line('{');
open c1;
loop
fetch c1 into rec;
exit when c1%notfound;
v_file_name := rec.file_name;
-- v_file_name := '+DATA';
dbms_output.put_line('set newname for datafile '||
lpad(rec.file_id,3)||
' to '''||
v_file_name||''';');
i := i + 1;
if mod(i,34) = 0
then i := 1;
j := j + 1;
end if;
k := k + 1;
end loop;
close c1;
dbms_output.put_line('}');
end;
/
Spool off

HOME