flashback 原理flashback的原理是执行之前的语句产生的undo
flashback: flashback->10 flackback->20
scn: 10 20 30
1------- 1->2 -------2->3 ------------------3->2-----------------------2->3------------------------
redo: 2->1 3->2 2->3 3->2
恢复数据库 : Flashback database to scn 123456
恢复drop,truncate的表:
flashback table a to before drop;
恢复dml的操作
方法1:
1.1 :
Select versions_xid,versions_startscn,versions_endscn,DECODE(versions_operation,'I','Insert','U','Update','D','Delete', 'Original') "Operation", id from A versions between scn minvalue and maxvalue;
(这里的id字段是用来指定A中具体哪条记录)
找到修改的记录的versions_startscn
1.2 :
alter table c enable row movement;
1.3 :
flashback table c to scn versions_startscn-1;
方法2:
2.1
SQL> alter database add supplemental log data;
只有在执行了这个句子之后的sql才会被记录undo_sql
2.2
Select xid,operation,commit_scn,undo_sql from flashback_transaction_query where xid in (
Select versions_xid from u1.t versions between scn minvalue and maxvalue);
找到相同的xid号对应的undo_sql,然后执行undo_sql
方法3:
Select versions_xid,versions_startscn,versions_endscn,DECODE(versions_
operation,'I','Insert','U','Update','D','Delete', 'Original') "Operation", id from A versions between scn minvalue and maxvalue;
VERSIONS_XID VERSIONS_STARTSCN VERSIONS_ENDSCN Operatio ID
---------------- ----------------- --------------- -------- ----------
05001A0054020000 1099482 Update 3 //
select * from A as of scn 1095782;