日期:2014-05-16 浏览次数:20583 次
探索ORACLE不完全恢复之--基于时间恢复
作者:吴伟龙 Name:Prodence Woo
QQ:286507175 msn:hapy-wuweilong@hotmail.com
基于时间(time)恢复
基于时间的恢复将数据库恢复到备份点与失败点之间的某个时间点。基于时间的恢复不仅在介质失败的时候使用,也可以在数据库正常运行的时候使用。例如:某个用户误删除了某个表的数据,这个时候我们可以通过基于时间的恢复来将删除的数据恢复出来,示例如下:
1、查看当前用户下的表,只有一张WWL001
21:07:31 SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ -----------------
WWL001 TABLE
Elapsed: 00:00:00.06
我们通过WWL001来创建WWL002-WWL005 共四张表用来测试不完全恢复
21:08:28 SQL> create table wwl002 asselect * from wwl001;
Table created.
Elapsed: 00:00:00.17
21:08:55 SQL> create table wwl003 asselect * from wwl001;
Table created.
Elapsed: 00:00:00.04
21:09:00 SQL> create table wwl004 asselect * from wwl001;
Table created.
Elapsed: 00:00:00.03
21:09:06 SQL> create table wwl005 asselect * from wwl001;
Table created.
Elapsed: 00:00:00.05
如上表已经创建完成
2、我们在21:13:13开始删除表(请注意时间)
21:13:13 SQL> drop table wwl002 purge;
Table dropped.
Elapsed: 00:00:00.16
21:13:28 SQL> drop table wwl003 purge;
Table dropped.
Elapsed: 00:00:00.11
21:13:34 SQL> truncate table wwl004;
Table truncated.
Elapsed: 00:00:00.32
21:13:44 SQL> truncate table wwl005;
Table truncated.
Elapsed: 00:00:00.07
21:13:47 SQL>
因为我们是要做基于时间的恢复,那么我们只有将数据库恢复到21:13:13之前的这个时间段,才能把我们刚才创建的表找回来。
3、开始执行恢复,先将数据库启动到mount状态
21:14:40 SQL> conn / as sysdba
Connected.
21:14:44 SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
21:15:20 SQL> startup mount;
ORACLE instance started.
Total System Global Area 100663296 bytes
Fixed Size 1217884 bytes
Variable Size 88083108 bytes
Database Buffers 8388608 bytes
Redo Buffers 2973696 bytes
Database mounted.
21:15:46 SQL> e
4、开始执行restore到备份数据库的当前状态:
RMAN> restore database;
Starting restore at 12-JUL-12
using target database control file insteadof recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=47 devtype=DISK
channel ORA_DISK_1: starting datafilebackupset restore
channel ORA_DISK_1: specifying datafile(s)to restore from backup set
restoring datafile 00001 to/DBBak2/oradata/WWL/system01.dbf