Home  >  Article  >  Database  >  Oracle 恢复误删除的表和误更新的表

Oracle 恢复误删除的表和误更新的表

WBOY
WBOYOriginal
2016-06-07 16:58:21910browse

不小心把Oracle一个表删除了。呵呵 查找了下恢复的方法 ,还真是简单啊根据ORACLE10G的特性,当我执行Drop Table或delete all时,

不小心把Oracle一个表删除了。呵呵 查找了下恢复的方法 ,还真是简单啊

根据ORACLE10G的特性,当我执行Drop Table或delete all时,Oracle都会把被删除的表或数据记录放到数据库回收站(Database Recyclebin)里。这样我们就可以用flashback table命令恢复被删除的表,,语法:
Flashback table 表名 to before drop;

sql@kokooa>flashback table test003 to before drop;

Flashback complete.

sql@kokooa>select * from test003;

NAME      STATE     PERSON
---- ---------- ----------
A             1
A             2
A             1
A             1
B             2
B             2

6 rows selected.

update的表

sql@kokooa>flashback table a to timestamp to_timestamp('2009-11-09 11:00:00','yyyy-mm-dd hh24:mi:ss');

一般会报错:

ERROR at line 1:
ORA-08189: cannot flashback the table because row movement is not enabled

只需要:

sql@kokooa>alter table a enable row movement;

Table altered.

就OK了

sql@kokooa>flashback table a to timestamp to_timestamp('2009-11-09 11:00:00','yyyy-mm-dd hh24:mi:ss');

Flashback complete.

sql@kokooa>select * from a;

NAME                        NUM
-------------------- ----------
jim                          90
tom                         100
kate                        220
lily                        330


默认情况下,oracle会对提交的数据做 1440 分钟,也就是一天的“缓存”,因此一天之内的数据是有办法找回的。

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn