利用閃回功能恢復刪除(drop,delete)的資料和表及資料,update之後資料恢復
從 flashback table 裡查詢被刪除的資料表
1、select * from recyclebin order by droptime desc
2、執行表的恢復
flashback table '需要恢復的表名' to before drop
二、delete表中資料1、先從 flashback_transaction_query 視圖裡查詢,檢視提供了供查詢用的表名稱、事務提交時間、undo_sql等欄位。
select * from flashback_transaction_query where table_name='需要恢復資料的表名(大寫)';
2、查詢刪除的時間點
select to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss') time,
to_char(dbms_flashback.get_system_change_number) scn
from dual;
3、記得刪除點,你也可以這樣試試查詢,找出刪除前的時間點
select * from '需要恢復資料的表名' as of timestamp to_timestamp('時間點', 'yyyy-mm-dd hh24:mi:ss');
4、進行資料恢復
通過第二步找到資料丟失的時間點,恢復極為簡單,語句為
flashback table '需要恢復資料的表名' to timestamp to_timestamp('資料丟失的前一時間點','yyyy-mm-dd hh24:mi:ss');
5、注意:在執行上述操作的時候,需要允許 oracle 修改分配給行的 rowid,這時候 oracle 需要給恢復的資料分配新的實體地址。
開啟行移動:alter table table_name enable row movement;
6、其實找到資料丟失前的時間點後,恢復資料也可以將需要恢復的資料直接插入到目標表中
insert into '資料丟失的表' select * from t of timestamp to_timestamp('時間點', 'yyyy-mm-dd hh24:mi:ss') where .......;
恢復結束後也可以關閉行移動:
alter table table_name disable row movement;
1、在v$sqlarea 這視圖裡面找到你操作那條SQL的時間;
select r.FIRST_LOAD_TIME,r.* from v$sqlarea r order by r.FIRST_LOAD_TIME desc;
2、把資料恢復到一個新表
create table t_table_recove --新表
as
select * from t_table--你操作後要恢復的那張表
as of timestamp to_timestamp('2010-06-02 11:36:53','yyyy-mm-dd hh24:mi:ss');
3、檢視t_table_recove 的資料是否是update前的資料
如果是則匯入原表,資料恢復成功