閃回技術的應用

2021-06-19 21:03:13 字數 2527 閱讀 3059

檢視開關狀態

select flashback_on from v$database;

開啟關閉

mount狀態

alter database on/off

執行閃回前,要允許行可移動

alter table xx enable row movement;

閃回資料庫

sql >flashback database to time to_date(『』,『』);

sql >flashback database to time to_timestamp (『』,『』);

sql >flashback database to scn ***

sql >flashback database to sequence *** thread 1

sql>flashback database to timestamp(sysdate-1/24)

注:修改timestamp格式 alter session set nls_timestamp_format='yyyy-mm-dd hh24:mi:ss';

2.閃回表

flashback table tablename to timestamp (jul-23-2013, 02:33:00) 

flashback table employee to scn 123456;

flashback table t1 to timestamp '2013-03-03 12:05:00' enable triggers;

3.閃回查詢

要執行閃回版本的查詢,可以使用select 命令的versions between子句。可以指定scntimestamp

select sal, versions_startscn, versions_operation from scott.emp versions between scn ***xx and ******x;

versions_startscn 資料第一次使值反射時的scn。如果為null,則行在查詢的下限之前建立。

select sal, versions_startscn, versions_operation from scott.emp versions between timestamp to_timestamp('12-dec-09 23.00.00', 'dd-mon-yy 

hh24.mi.ss') and to_timestamp('12-dec-09 23.06.00', 'dd-mon-yy hh24.mi.ss');

select versions_starttime, versions_endtime, versions_xid,

versions_operation, a,b

from test

versions between timestamp minvalue and maxvalue

scn  min and max

where   ..

order by versions_starttime;

4.閃回事務

select operation,undo_sql,table_name

from flashback_transaction_query

where xid=hextoraw('***')

start_timestamp >=to_timestamp() and commit_timestamp<=to_timestamp()  [logon_user table_owner start_scn]

order by..

nocascade, 事務1不可被任何其它事務依賴,否則撤銷操作報錯

cascade,將事務1同事務2一起撤銷。

nocascade_force,忽略事務2,直接執行事務1的撤銷sql,如果沒有約束衝突,操作成功,否則約束報錯導致撤銷操作失敗

nonconfilict_only,在不影響事務2的前提下,撤銷事務1的修改。與nocascade_force的不同在於首先過濾一下事務1的撤銷sql,確保他們不會作用在事務2的修改的行上

eg: select distinct xid,commit_scn,undo_sql from flashback_transaction_query  where table_owner='scott' and table_name='emp'

and commit_timestamp > systimestamp - interval '15' minute order by commit_scn;

declare

xids sys.xid_array;

begin

xids :=sys.xid_array('0a00160094020000');

dbms_flashback.transaction_backout(1,xids,options=>dbms_flashback_nocascade);

end;

/5閃回drop

flashback table xx to before drop rename to xx2; 

oracle閃回技術

1,閃回資料庫到之前某時間點 在安裝時需要開放閃回功能 不支援表空間刪除 select name from v database 看是否開啟閃回功能 select flashback on,name from v database select name from v bgprocess where...

oracle閃回技術

查詢某一時刻資料庫中資料狀態語句 select from abc as of timestamp to timestamp 2015 08 24 10 31 00 yyyy mm dd hh24 mi ss 閃回dml語句 flashback table abc to timestamp to ti...

Oracle 閃回技術

允許復原資料庫到某個時間點,從而撤銷自該時間以後的所有更改。主要利用閃回日誌檢索資料塊的舊版本,同時它也依賴歸檔重做日誌完全地恢復資料庫,不用復原資料檔案和執行傳統的介質恢復 閃回前提 資料庫為歸檔模式 查詢當前資料庫是否為歸檔模式 archive log list 非歸檔執行如下 歸檔跳過 shu...