根據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 分鐘,也就是一天的“緩存”,因此一天之內的數據是有辦法找回的。