1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| set linesize 500 set pagesize 500 col file_name for a60 select 'set newname for datafile '||file_id||' to ''/einvuatdb/data/'||substr(file_name, instr(file_name, '/', -1) + 1) || ''';' from dba_data_files;
set linesize 500 pagesize 500 set echo off set term off set feedback off set heading off col file# for a60 select 'set newname for datafile '||file#||' to ''/ngprdb/data/'||substr(name, instr(name, '\', -1) + 1) || ''';' from v$dbfile;
run { set newname for datafile 1 to '/data/system01.dbf'; switch datafile all; }
RMAN> catalog start with '/qunhui/Oracle.CRM.Backup/172.17.13.94/';
run { allocate channel ch1 type disk; allocate channel ch2 type disk; allocate channel ch3 type disk; allocate channel ch4 type disk; allocate channel ch5 type disk; allocate channel ch6 type disk; set newname for database to '+DATADG'; set until time "to_date('20230403 01:00:00' , 'yyyymmdd hh24:mi:ss')"; restore database ; release channel ch1; release channel ch2; release channel ch3; release channel ch4; release channel ch5; release channel ch6; }
RMAN> switch database to copy;
第一组 switch dtabase to copy; switch datafile number|name to copy; switch tablespace name to copy;
第二组 switch datafile all; switch datafile number|name; switch tempfile all;
Oracle12c容器数据库: 替换GUID值:
col name for a100 set linesize 800 pagesize 800 select replace(db.name, pdb.guid , pdb.name) from v$dbfile db, v$pdbs pdb where db.con_id=pdb.con_id union select db.name from v$dbfile db where db.con_id not in (select con_id from v$pdbs);
col name for a100 set linesize 800 pagesize 800 select case when db.con_id=pdb.con_id then replace(db.name, pdb.guid , pdb.name) else db.name end as name from v$dbfile db left join v$pdbs pdb on (db.con_id=pdb.con_id);
col name for a100 set linesize 800 pagesize 800 select 'alter database rename file '||''''|| db.name||''''|| ' to ' ||''''|| case when db.con_id=pdb.con_id then replace(replace(db.name, pdb.guid , pdb.name), '+DATADG', '/Ora18cData') else replace(db.name, '+DATADG', '/Ora18cData') end ||''''||';' as name from v$dbfile db left join v$pdbs pdb on (db.con_id=pdb.con_id);
col name for a100 set linesize 800 pagesize 800 select 'alter database rename file '||''''|| db.name||''''|| ' to ' ||''''|| case when db.con_id=pdb.con_id then replace(replace(replace(db.name, pdb.guid , pdb.name), '+DATADG', '/Ora18cData'), '/DATAFILE/', '/') else replace(replace(db.name, '+DATADG', '/Ora18cData'), '/DATAFILE/', '/') end ||''''||';' as name from v$dbfile db left join v$pdbs pdb on (db.con_id=pdb.con_id);
|