oracle truncate闪回数据库恢复

1、创建试验表

conn scott/tiger

create table truncate_test as select * from user_objects;

select count(*) from truncate_test;

 

2、记录truncate table 的时间,但在生产中是不知道准确的时间的只能尝试找时间点了

SQL> select to_char(systimestamp,'yyyy-mm-dd hh24:mi:ss.FF9') from dual;

TO_CHAR(SYSTIMESTAMP,'YYYY-MM
-----------------------------
2009-11-06 17:15:18.406000000


3、截断表
truncate table truncate_test;
select * from truncate_test;

shutdown immediate

startup mount


flashback database to timestamp
to_timestamp('2009-11-06 17:15:18','yyyy-mm-dd hh24:mi:ss');
闪回完成。

alter database open read only;

select * from scott.truncate_test;

发现数据已经找回来了,这样就可以吧数据库online了

4、看看在此时表是否恢复回来了,如果没有恢复回来,重新选择时间点

startup mount
alter database open resetlogs

select * from scott.truncate_test;

这属于不完全恢复

出处:http://blog.163.com/card_2005/blog/static/11781036820091065501988/

posted on 2014-12-18 14:48  jack_Meng  阅读(4704)  评论(0编辑  收藏  举报

导航