输入banner图图片脚本导航/分类

Oracle恢复删除数据

一、通过SCN恢复删除且已经提交的数据

  • 查询当前SCN
select current_scn from v$database; 

  如图:

技术分享图片

  • 缩小范围进行查询

  查询到当前的SCN为14543776308552,查询当前SCN之前的SCN对应的表数据。

select * from 表名 as of scn 14543776308550; -- 确定删除的数据是否存在,如存在,则恢复数据;否则继续缩小scn号
  • 恢复数据
flashback table 表名 to scn 14543776308550;

二、通过时间戳进行恢复

  • 查询当前的系统时间
select to_char(sysdate, yyyy-mm-dd hh24:mi:ss) from dual;
  • 查询删除数据时间点之前的数据
select * from 表名 as of timestamp to_timestamp(2018-02-13 15:48:00, yyyy-mm-dd hh24:mi:ss); -- 如果不是,则继续缩小时间范围
  • 恢复数据
flashback table 表名 to timestamp to_timestamp(2018-02-13 15:48:00,yyyy-mm-dd hh24:mi:ss);

   备注:如果执行恢复数据SQL出现错误,可以执行: alter table 表名 enable row movement; //允许更改时间戳

 

Oracle恢复删除数据

标签:date   inf   tab   ble   nbsp   img   strong   两种方法   amp