Flashback - The Time Machine..
-
Upload
navneet-upneja -
Category
Technology
-
view
256 -
download
8
Transcript of Flashback - The Time Machine..
FLASHBACK
• Access to past much like a time machine.
• Useful in case of User Errors or Logical Errors.
• Can rollback Transaction with Database still remains Online.
• Can be helpful to see the history of changes to data.
• Can recover Table or database to point in time in the past.
• New buffer in SGA: Flashback Buffer
• New Background process: RVWR
FLASHBACK TECHNOLOGIES
• Flashback Query
• Flashback Table
• Flashback Versions Query
• Flashback Transaction Query
• Flashback Transaction
• DBMS_FLASHBACK
• Flashback Drop
• Flashback Database
FLASHBACK QUERY
• Query data in the past.
• Depends upon the data availability in Undo segments.
• Can be used to recover lost data or undo some transaction.
• Is used by using SELECT AS OF
• Takes around 6 sec to record the flashback record.
• SELECT * FROM FL_QUERY AS OF TIMESTAMP TO_TIMESTAMP('×tamp','DD-MON-YY HH24.MI.SS');
FLASHBACK VERSION QUERY
• Retrieve different versions of rows during a given interval.
• Versions Between clause of Select statement is used. • Pseudocolumns are used:
• Versions_startscn
• Versions_starttime
• Versions_endscn
• Versions_endtime
• Versions_xid
• Versions_operation
• Scripts used: fl_version_upd.sql fl_version.sql
FLASHBACK TRANSACTION QUERY
• Retrieve Metadata and historical data for transaction/transactions.
• flashback_transaction_query view is used to see the past transaction data.
SELECT xid, operation, start_scn, commit_scn, logon_user, undo_sql
FROM flashback_transaction_query
WHERE xid in (select versions_xid from fl_query versions BETWEEN TIMESTAMP TO_TIMESTAMP('29-MAY-14 16.40.54', 'DD-MON-YY HH24.MI.SS') AND TO_TIMESTAMP('29-MAY-14 16.49.56', 'DD-MON-YY HH24.MI.SS'));
FLASHBACK TABLE
• Will flashback a table to some time in past.
• Use undo to flashback the table.
• This is not a rollback, it’s a separate transaction. • Flashback table keep the constraints intact.
• Enable Row movement on tables before Flashback table.
DBMS_FLASHBACK
• Package used to rollback transaction/s.
• Subprograms:
• Enable_At_time
• Transaction_backout
• Disable
• Must have Flashback any table privilege. Example: exec
dbms_flashback.transaction_backout(numtxns=>1,xids=>sys.xid_array('030020006D070000'),options=>dbms_flashback.cascade);
FLASHBACK DROP
• Getting back the dropped table.
• Table is recreated (Re-named) from recycle bin.
• Depends upon the availability of dropped table in recycle bin.
• Cannot recover a table from dropped schema.
Flashback table drop_table to before drop;
FLASHBACK DATABASE
• Flashback Database to time in the past.
• Needs Resetlogs to open the database.
• Similar to point in time recovery but takes less time and less complex.
• Db_recovery_file_dest=/data3/oracle/fast_recovery_area/
• Db_flashback_retention_target=1440;
• Db_recovery_file_Dest=10G;
• Alter database Flashback on;
• Flashback database to timestamp to_timestamp('30-may-2014 14:51:09','dd-mon-yyyy hh24:mi:ss');
• Alter database open resetlogs;
• Restore Points
• create restore point BEFORE_UPGRADE;
• create restore point BEFORE_UPGRADE guarantee flashback database;
• drop restore point BEFORE_UPGRADE;
SUMMARY
• Flashback Query – no setup required – Just undo
• Flashback Table – no setup required – Just undo
• Flashback Drop – Recyclebin – on by default.
• Flashback Versions - no setup required – Just undo
• Flashback Database – Requires a flash recovery area / feature to be switched on.
• Flashback Transaction – may require supplimental data
• Flashback Data Archives – needs flashback tablespace