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;