Tuesday, June 26, 2012

Flashback primary database in a dataguard environment

Following steps have been tested in Oracle 10.2

1, On primary database, Stop dataguard broker.
>alter system set dg_broker_start = false;

2, Flashback database to SCN
>shutdown immediate;
>startup mount;
>flashback database to SCN ;
>alter database open resetlog;
>alter system set dg_broker_start = true;


3, Determine the SCN before the RESETLOGS operation occurred.
> SELECT TO_CHAR(RESETLOGS_CHANGE# - 2) FROM V$DATABASE; --should be same as 

4, Obtain the current SCN on the standby database.
>SELECT TO_CHAR(CURRENT_SCN) FROM V$DATABASE;


5, Determine if it is necessary to flash back the standby database.

If the value of CURRENT_SCN is larger than the value of resetlogs_change# - 2(), issue the following statement to flash back the standby database.
>FLASHBACK STANDBY DATABASE TO SCN resetlogs_change# -2;

•If the value of CURRENT_SCN is less than the value of the resetlogs_change# - 2, skip to Step 6.


6, Restart Redo Apply.

>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;