`
xmt721
  • 浏览: 3372 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

Oracle中恢复某张表丢失数据的方法

阅读更多
Oracle中恢复某张表丢失数据的方法
2010-05-15 16:55

--利用ORACLE数据库的SCN进行恢复,ORACLE数据库每隔5分钟,系统会产生一个系统时间标记与scn的匹配并存入sys.smon_scn_time表中。

--我们对这个备份机制做如下测试

--查询出来数据
select t.*, t.rowid from account t where id >10000 order by t.id asc;

--删掉数据
delete from account c where c.id >10000;

--查询出ORACLE数据库中的scn与时间的对应关系
select * from sys.smon_scn_time order by time_dp desc;

--根据数据取得删除时间段对应的SCN号,这里是1693760, 查看这个检查点的account表的历史情况
select * from account as of scn 1693760;

-- 将account表复制一个,(这里表的关联关系需要另外处理),命名为account_new 。
create table account_new as select * from account where 1<>1

--将删掉的数据库从这个检查点恢复到新表account_new中。
insert into account_new (select * from account as of scn 1693760);

--查询恢复后的结果。
select * from account_new;

--- 此方法的最佳恢复时间越短越好,如果超过了24个小时,恢复的可能性就很小了。

引用自:http://hi.baidu.com/no9988/blog/item/c1dc2fecaf92da2b62d09ff6.html

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics