(一) 使用备份时的控制文件进行恢复,如下图,即使用备份位置的控制文件进行恢复

1) 创建测试表空间ts1及相关测试表(表空间为ts1)
SYS@ORCL>create tablespace ts1 datafile '/u01/app/oracle/oradata/ORCL/ts1.dbf' size 10m;
Tablespace created.
SYS@ORCL>create table scott.t(x int) tablespace ts1;
Table created.
SYS@ORCL>insert into scott.t select rownum from dual connect by rownum<=10;
10 rows created.
SYS@ORCL>commit;
Commit complete.
SYS@ORCL>
2) 通过RMAN备份ts1表空间和控制文件
RMAN> backup tablespace ts1 include current controlfile;
Starting backup at 17-JAN-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=141 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00006 name=/u01/app/oracle/oradata/ORCL/ts1.dbf
channel ORA_DISK_1: starting piece 1 at 17-JAN-13
channel ORA_DISK_1: finished piece 1 at 17-JAN-13
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_01_17/o1_mf_nnndf_TAG20130117T101646_8hgqrg9h_.bkp tag=TAG20130117T101646 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
channel ORA_DISK_1: starting piece 1 at 17-JAN-13
channel ORA_DISK_1: finished piece 1 at 17-JAN-13
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_01_17/o1_mf_ncnnf_TAG20130117T101646_8hgqrhvd_.bkp tag=TAG20130117T101646 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 17-JAN-13
RMAN>
3) 删除t表部分记录
SYS@ORCL>delete scott.t where x>=6;
5 rows deleted.
SYS@ORCL>commit;
Commit complete.
SYS@ORCL>
4) 切换几次日志,让上面的动作归档(对于测试来说,意义不是特别的大)
SYS@ORCL>alter system switch logfile;
System altered.
SYS@ORCL>/
System altered.
SYS@ORCL>/
System altered.
SYS@ORCL>/
System altered.
SYS@ORCL>
5) 在users表空间上创建t1表
SYS@ORCL>create table scott.t1(x int) tablespace users;
Table created.
SYS@ORCL>insert into scott.t1 select rownum from dual connect by rownum<=2;
2 rows created.
SYS@ORCL>commit;
Commit complete.
SYS@ORCL>
6) 将表ts1修改为只读模式
SYS@ORCL>alter tablespace ts1 read only;
Tablespace altered.
SYS@ORCL>select tablespace_name,status from dba_tablespaces where tablespace_name='TS1';
TABLESPACE_NAME STATUS
------------------------- ---------
TS1 READ ONLY
SYS@ORCL>select file_id,file_name,status,online_status from dba_data_files where tablespace_name='TS1';
FILE_ID FILE_NAME STATUS ONLINE_
---------- --------------------------------------------- --------- -------
6 /u01/app/oracle/oradata/ORCL/ts1.dbf AVAILABLE ONLINE
SYS@ORCL>
7) 删除ts1表空间数据文件和所有控制文件
SYS@ORCL>!rm /u01/app/oracle/oradata/ORCL/ts1.dbf
SYS@ORCL>!rm /u01/app/oracle/oradata/ORCL/*.ctl
8) 重启数据库到nomount状态
SYS@ORCL>shutdown abort;
ORACLE instance shut down.
SYS@ORCL>
SYS@ORCL>startup nomount;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 96470608 bytes
Database Buffers 184549376 bytes
Redo Buffers 2973696 bytes
SYS@ORCL>
9) 通过RMAN备份的控制文件完成控制文件的恢复,恢复完成,数据库修改为mount
RMAN> restore controlfile from '/u01/app/oracle/flash_recovery_area/ORCL/backupset/201