Monday, April 11, 2011

Just press the Rewind button for your database


It actually allows you to return a database to its state at a time in the recent past. It is much faster than point-in-time recovery, because it does not require restoring datafiles from backup and it requires applying fewer changes from the archived redo logs.
To enable Flashback Database, you set up a flash recovery area, and set a flashback retention target, to specify how far back into the past you want to be able to restore your database with Flashback Database.
From that time on, at regular intervals, the database copies images of each altered block in every datafile into flashback logs stored in the flash recovery area. These block images can later be re-used to reconstruct the datafile contents as of any moment at which logs were captured.
Enable the Flashback Database feature for the  database:

SQL> ALTER DATABASE FLASHBACK ON;

The V$FLASHBACK_DATABASE_LOG view can help you decide how much space to add to your flash recovery area for flashback logs..

SQL> SELECT ESTIMATED_FLASHBACK_SIZE FROM V$FLASHBACK_DATABASE_LOG;

At any given time, the earliest point in time to which you can actually rewind your database by using Flashback Database can be determined by querying theV$FLASHBACK_DATABASE_LOG view as shown in this example:

SELECT OLDEST_FLASHBACK_SCN, OLDEST_FLASHBACK_TIME 
      FROM V$FLASHBACK_DATABASE_LOG;
 
RMAN> FLASHBACK DATABASE 
  TO TIME to_timestamp('2011-12-11 16:00:00', 'YYYY-MM-DD HH24:MI:SS');