Thursday, May 15, 2008

Can you use flashback database if a period of noarchivelog exists

The scenario is I have enabled flashback feature. Now I have ran the database in noarchivelog mode for some time and then I again enable archivelog mode. Now can I get back to a point to previous flashback point. The answer is no. The minimum requirement to enable flashback database is to keep the database in Archive log mode.

Because in order to switch from noarchivelog mode to archivelog mode you have to disable flashback logging and so you lose the logs unless you have guaranteed restore point.

But if you have guaranteed restore point then you can't switch from noarchivelog mode to archivelog mode and hence you can perform flashback.

In the following section the whole scenario is described with example.

SQL> alter database flashback on;
Database altered.

SQL> alter database open;
Database altered.

SQL> update arju.a set col1=col1+1;
1 rows updated.

SQL> commit;
Commit complete.

SQL> create restore point normal;
Restore point created.

SQL> update arju.a set col1=col1+1;
1 rows updated.

SQL> commit;
Commit complete.

SQL> alter system switch logfile;

System altered.

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

SQL> startup mount;
ORACLE instance started.
.
database mounted.

SQL> alter database noarchivelog;
alter database noarchivelog
*
ERROR at line 1:
ORA-38774: cannot disable media recovery - flashback database is enabled

SQL> alter database flashback off;
Database altered.

SQL> alter database noarchivelog;
Database altered.

SQL> alter database open;
Database altered.

SQL> update arju.a set col1=col1+1;
1 rows updated.

SQL> commit;
Commit complete.

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

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

SQL> alter database archivelog;
Database altered.

SQL> alter database flashback on;
Database altered.

SQL> flashback database to restore point normal;
flashback database to restore point normal
*
ERROR at line 1:
ORA-38729: Not enough flashback database log data to do FLASHBACK.


SQL> select name from v$restore_point;
NAME
--------------------------------------------------------------------------------
NORMAL

SQL> show parameter DB_FLASHBACK_RETENTION_TARGET
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_flashback_retention_target integer 1440

SQL> create restore point g_restore guarantee flashback database;
Restore point created.

SQL> alter database open;

Database altered.

SQL> update arju.a set col1=col1;
1 rows updated.

SQL> commit;
Commit complete.

SQL> alter system switch logfile;

System altered.

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

SQL> startup mount;

ORACLE instance started.
.
Database mounted.

SQL> alter database flashback off;
Database altered.

SQL> alter database noarchivelog;
alter database noarchivelog
*
ERROR at line 1:
ORA-38781: cannot disable media recovery - have guaranteed restore points

So, the minimum requirement to enable flashback database is to keep the database in Archive log mode.
Related Documents
arjudba.blogspot.com/2008/04/performing-flashback-database.html
arjudba.blogspot.com/2008/04/restore-point-and-flashback-database.html
arjudba.blogspot.com/2008/05/ora-08189-cannot-flashback-row-movement.html
arjudba.blogspot.com/2008/05/flashback-on-fails-with-ora-38706-and.html
arjudba.blogspot.com/2008/04/how-to-enable-flashback-database.html
arjudba.blogspot.com/2008/04/flashback-database-to-undo-open.html

No comments:

Post a Comment