思路:
o 利用RMAN对数据文件做copy
o 将数据文件offline
o switch文件名,这一步将更改控制文件中数据文件对应的文件名
o recover数据文件
o 将数据文件online,恢复生产
注:也可以利用这种思路做DATABASE COPY,然后做SWITCH DATABASE,迁移数据库...
实验过程如下:
======================================
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle/arch
Oldest online log sequence 63
Next log sequence to archive 65
Current log sequence 65
RMAN> report schema;
using target database control file instead of recovery catalog
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 700 SYSTEM *** /u01/app/oracle/oradata/ora10g/system01.dbf
2 700 UNDOTBS1 *** /u01/app/oracle/oradata/ora10g/undotbs01.dbf
3 260 SYSAUX *** /u01/app/oracle/oradata/ora10g/sysaux01.dbf
4 5 USERS *** /u01/app/oracle/oradata/ora10g/users01.dbf
5 5 USERS *** /u01/app/oracle/oradata/ora10g/users02.dbf <<<<<<<<计划将5号数据文件重命名
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 30 TEMP 32767 /u01/app/oracle/oradata/ora10g/temp01.dbf
RMAN> backup as copy datafile 5 format ‘/u01/app/oracle/oradata/ora10g/users02_new.dbf‘;
Starting backup at 05-FEB-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=146 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=/u01/app/oracle/oradata/ora10g/users02.dbf
output filename=/u01/app/oracle/oradata/ora10g/users02_new.dbf tag=TAG20150205T225207 recid=1 stamp=870907927
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 05-FEB-15
SQL> alter database datafile 5 offline;
Database altered.
SQL> recover datafile 5;
Media recovery complete.
SQL> alter database datafile 5 online;
Database altered.
RMAN> report schema;
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 700 SYSTEM *** /u01/app/oracle/oradata/ora10g/system01.dbf
2 700 UNDOTBS1 *** /u01/app/oracle/oradata/ora10g/undotbs01.dbf
3 260 SYSAUX *** /u01/app/oracle/oradata/ora10g/sysaux01.dbf
4 5 USERS *** /u01/app/oracle/oradata/ora10g/users01.dbf
5 5 USERS *** /u01/app/oracle/oradata/ora10g/users02_new.dbf <<<<<<<<<<<<<<<<<<文件名已更换
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 30 TEMP 32767 /u01/app/oracle/oradata/ora10g/temp01.dbf
原文地址:http://blog.csdn.net/robo23/article/details/43539819