ORACLE恢复删除的数据
在网络搜集整理了关于恢复oracle已经删除或更新的数据方法,供参考;
oracle提供了针对已经删除的数据恢复;分为两种方法:scn和时间戳两种方法恢复。
一、通过scn恢复删除且已提交的数据
1、获得当前数据库的scn号
select current_scn from v$database; (切换到sys用户或system用户查询)
查询到的scn号为:1499223
2、查询当前scn号之前的scn
select * from 表名 as of scn 1499220; (确定删除的数据是否存在,如果存在,则恢复数据;如果不是,则继续缩小scn号)
3、恢复删除且已提交的数据
flashback table 表名 to scn 1499220;
二、通过时间恢复删除且已提交的数据
1、查询当前系统时间
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
2、查询删除数据的时间点的数据
select * from 表名 as of timestamp to_timestamp('2013-05-29 15:29:00','yyyy-mm-dd hh24:mi:ss'); (如果不是,则继续缩小范围)
3、恢复删除且已提交的数据
flashback table 表名 to timestamp to_timestamp('2013-05-29 15:29:00','yyyy-mm-dd hh24:mi:ss');
注意:如果在执行上面的语句,出现错误。可以尝试执行 alter table 表名 enable row movement; //允许更改时间戳
三、oracle数据update后怎么恢复到以前的数据
--查出你需要恢复的时间点
1、select * from V$SQL where SQL_TEXT like '%update MAP_OPTCBL_POINT_70 set shape%'
--创建新的表
2、create table t_table_recove
as select * from MAP_OPTCBL_POINT_70 --你误操作的表
as of timestamp to_timestamp('2013-09-23 11:38:46','yyyy-mm-dd hh24:mi:ss');--时间点
--得到你想要的数据
3、delete MAP_OPTCBL_POINT_70;--将原表的数据全部删除
4、insert into MAP_OPTCBL_POINT_70 select * from t_table_recove;--恢复数据
本文介绍如何使用Oracle数据库的闪回特性来恢复已删除或更新的数据。包括通过SCN和时间戳两种方法恢复删除数据,以及如何恢复更新后的数据到之前的状态。
1680

被折叠的 条评论
为什么被折叠?



