将数据库、表空间、数据文件等恢复至恢复备份集保存时间中的任何一个时间点/SCN/日志序列(一般是日志挖掘找到误操作点),但须谨慎,操作前一定需要做好备份,具备条件的情况下最好先恢复到异机,避免业务停机时间。
前提:已经有数据库备份 (作者已经提前准备了备份,这里不进行备份,为了节约空间)
--准备实验环境
SQL> select * from andy.andy;
select * from andy.andy
*
ERROR at line 1:
ORA-00942: table or view does not exist
--不完全恢复时间点
SQL> select to_char(sysdate, ‘YYYY-MM-DD HH24:MI:SS‘) from dual;
TO_CHAR(SYSDATE,‘YY
-------------------
2015-03-25 07:55:12
SQL> create table andy.andy(id int);
Table created.
SQL> insert into andy.andy values(1);
1 row created.
SQL> insert into andy.andy values(100);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from andy.andy;
ID
----------
1
100
1 基于时间点
方法一: 在RMAN中执行
RMAN>
run{
startup mount force;
set until time "to_date(‘2015-03-25 07:55:12‘,‘yyyy-mm-dd hh24:mi:ss‘)";
restore database;
recover database;
alter database open resetlogs;
}
Finished recover at 25-MAR-15
database opened
--恢复时间点之后的表不见了,说明的确是不完全恢复。
SQL> select * from andy.andy;
select * from andy.andy
*
ERROR at line 1:
ORA-00942: table or view does not exist
——————————————————————————
方法二:在SQLplus中执行
SQL>startup mount force;
SQL>alter session set nls_date_format=‘yyyy-mm-dd hh24:mi:ss‘;
SQL>restore database until time "to_date(‘2015-03-25 07:55:12‘,‘YYYY-MM-DD HH24:MI:SS‘)";
SQL>recover database until time "to_date(‘2015-03-25 07:55:12‘,‘YYYY-MM-DD HH24:MI:SS‘)";
SQL>alter database open resetlogs;
2 基于 SCN:
SQL>startup mount force;
SQL>restore database until scn XXXX;
SQL>recover database until scn XXXX;
SQL>alter database open resetlogs;
3 基于日志序列
SQL>startup mount force;
SQL>restore database until SEQUENCE 100 thread 1; //100是日志序列
SQL>recover database until SEQUENCE 100 thread 1;
SQL>alter database open resetlogs;