Monday 20 April 2009

Restore the Entire Database with Flashback

Don't know how this will work on a large database, but looks like the easiest way to restore the entire Oracle database. On a home grown database, 3GB, it took just a few seconds.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance
shut down.

SQL> startup mount exclusive;
ORACLE instance started.
Database mounted.

SQL> FLASHBACK DATABASE to timestamp to_timestamp('20-04-2009 10:00', 'DD-MM-YYYY HH24:MI:SS');
Flashback complete.

SQL> alter database open resetlogs;

If on the other hand you are ok to just recover the database to the last scn, for example a Table has been accidentally truncated in a DWH, and no transactional activity had taken place before the truncate, you can recover the database back to the scn, using Flashback by

sql> select current_scn from v$database;

Current SCN
------------
2592544

Table truncated

sql> Connect / as sysdba
connected.

sql>shutdown immediate;
Database closed.
Database dismounted
ORACLE instance shutdown.

sql> Startup Mount;

sql>flashback database to scn 2592544;
Flashback complete

sql> alter database open resetlogs;

No comments: