truncate数据恢复
在没有开启闪回数据库,undo也过了保留期限(和undo没啥关系,truncate不记录redo和undo)。因为当truncate命令发起之后,oracle实际上兵没有在删除底层数据块上的数据,而是要等到重用的时候才会把这部分回收,于是这给了我们一个能够恢复数据库的机会
1.安装一个包,这个包的下载地址http://www.hellodba.com/reader.php?ID=216&lang=CN
sql>@E:\1ys\FY_Recover_Data.pck
2.创建实验表并truncate
create table test1 as select * from user_objects;
select count() from test1;
truncate table test1;
3.通过脚本恢复数据,恢复的表是test1$$
exec fy_recover_data.recover_truncated_table('SYS','TEST1')
select count() from test1; (发现没有数据)
select count() from test1$$;(有数据)
4.把数据插回原表
alter table test1 nologging;
insert /+ append/ into test1 select * from test1$$;
commit;
alter table test1 logging;
select count() from test1;
注意:紧急救急,只要块没复写,都能恢复。生产环境最好不要使用

浙公网安备 33010602011771号