oracle数据误删后恢复数据操作

平时工作中,常有这种情况,一些表还来不及备份,就做了误删除操作。怎么恢复呢,其实很简单,下面三步就可以做到:
1)将删除数据之前的时间(数据还存在的时间)转换为scn;
SQL> select timestamp_to_scn(to_timestamp(‘2011-03-23 17:22:00’,’yyyy-mm-dd hh24:mi:ss’)) from dual;
**TIMESTAMP_TO_SCN(TO_TIMESTAMP(‘2011-03-2317:22:00’,’YYYY- MM-DDHH24:MI:SS’))
—————————————————————————**
117872363
2)验证这个scn点时数据的存在;
SQL> select count(*) from w as of scn 117872363;
*COUNT()
———-**
72558
3)创建基于原表数据还存在时的临时表;
SQL> create table q as select * from w as of scn 117872363;
Table created.
以上语句由两条语句合并而成:
SQL> create table q as select * from w where 1 = 0;
Table created.
SQL> insert into q select * from w as of scn 117872363;
72558 rows created.

好了,经过这样三步,丢失的数据找回来了。

发布了28 篇原创文章 · 获赞 2 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/u012733521/article/details/51982108
今日推荐