根据ORACLE10G的特性,当我执行Drop Table或delete all时,Oracle都会把被删除的表或数据记录放到数据库回收站(Database Recyclebin)里。这样我们就可以用flashback table命令恢复被删除的表,语法:
Flashback table 表名 to before drop;
table test003 to before drop;
Flashback complete.
* from test003;
NAME STATE PERSON
---- ---------- ----------
A 1
A 2
A 1
A 1
B 2
B 2
6 rows selected.
update的表
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
只需要:
table a enable row movement;
Table altered.
就OK了
table a to timestamp to_timestamp('2009-11-09 11:00:00','yyyy-mm-dd hh24:mi:ss');
Flashback complete.
* from a;
NAME NUM
-------------------- ----------
jim 90
tom 100
kate 220
lily 330
[SYS@ora10gr1#2009-11-04/08:42:53] SQL>show parameter db_flashback_retention_target
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_flashback_retention_target integer 1440
默认情况下,oracle会对提交的数据做 1440 分钟,也就是一天的“缓存”,因此一天之内的数据是有办法找回的。