Monday, 30 March 2015

Oracle Database Incarnations

Whenever you open the database with the command ALTER DATABASE OPEN RESETLOGS, a new incarnation is created. Performing an OPEN RESETLOGS do the following,

-Archives the current online redo logs,

-Incarnation resets the log sequence number to 1, and then

-Gives the online redo logs a new time stamp and SCN.

-Increments the incarnation number, which is used to uniquely tag and identify a stream of redo.

Parent, Ancestor and Sibling Database Incarnations
 
-The incarnation from which the current incarnation branched following an OPEN  RESETLOGS operation is called the parent incarnation of the current incarnation.

-The parent incarnation and all of its parent incarnations are the ancestor incarnations of the current incarnation.

-Two incarnations that share a common ancestor are sibling incarnations if neither one are an ancestor of the other.

-To view the incarnation history of a database use with command.

RMAN>LIST INCARNATION;

-By default, when used command likes FLASHBACK DATABASE or RECOVER... UNTIL, an SCN is assumed to refer to the current incarnation path, rather than sibling incarnations.

-However, you can use the RESET DATABASE TO INCARNATION command to specify that SCNs are to be interpreted in the frame of reference of another incarnation.

-For example my current database INCARNATION is 5 and now I have used
 
FLASHBACK DATABASE TO SCN 6666;  

then SCN 6666 will be search in current incarnation which is 5. However if I want to get back to SCN 6666 of INCARNATION 4 then I have to use,

RMAN> RESET DATABASE TO INCARNATION 4;
RMAN> RECOVER DATABASE TO SCN 6666;


-When a database goes through multiple incarnations, some backups can become orphaned. Orphaned backups are backups that are created during incarnations of the database that are not ancestors of the current incarnation.

-For example, database incarnation is 5 and SCN is 7000. A DBPITR is done at SCN 7000 to SCN 6666 and then RESETLOGS is performed. Now in current incarnation 6 the backup taken between 6666 and 7000 SCN became orphaned.

-Orphaned backups are usable by RMAN in cases where you wish to restore the database to a point in time not in the current incarnation path. 

**Interview questions and answers on oracle database Incarnation. **

Q. What happens when you run ALTER DATABASE OPEN RESETLOGS ?
The current online redo logs are archived, the log sequence number is reset to 1, new database incarnation is created, and the online redo logs are given a new time stamp and SCN.



Q. In what scenarios open resetlogs required ?
An ALTER DATABASE OPEN RESETLOGS statement is required after incomplete recovery (Point in Time Recovery) or recovery with a backup control file.


Q. What is SCN (System Change Number) ?
The system change number (SCN) is an ever-increasing value that uniquely identifies a committed version of the database at a point in time. Every time a user commits a transaction Oracle records a new SCN in redo logs.

Oracle uses SCNs in control files datafile headers and redo records. Every redo log file has both a log sequence number and low and high SCN. The low SCN records the lowest SCN recorded in the log file while the high SCN records the highest SCN in the log file.





Q. What is Database Incarnation ?




Database incarnation is effectively a new version of the database that happens when you reset the online redo logs usingalter database open resetlogs;”.
Database incarnation falls into following category Current, Parent, Ancestor and Sibling

i) Current Incarnation : The database incarnation in which the database is currently generating redo.

ii) Parent Incarnation : The database incarnation from which the current incarnation branched following an OPEN RESETLOGS operation.

iii) Ancestor Incarnation : The parent of the parent incarnation is an ancestor incarnation. Any parent of an ancestor incarnation is also an ancestor incarnation.

iv) Sibling Incarnation : Two incarnations that share a common ancestor are sibling incarnations if neither one is an ancestor of the other.


Q. How to view incarnation history of Database ?

Using SQL> select * from v$database_incarnation;
 

Using RMAN>LIST INCARNATION;

However, you can use the RESET DATABASE TO INCARNATION command to specify that SCNs are to be interpreted in the frame of reference of another incarnation.

-For example my current database INCARNATION is 3 and now I have used
 

FLASHBACK DATABASE TO SCN 3000;

then SCN 3000 will be search in current incarnation which is 3. However if I want to get back to SCN 3000 of INCARNATION 2 then I have to use,
 
RMAN> RESET DATABASE TO INCARNATION 2;
 

RMAN> RECOVER DATABASE TO SCN 3000;





 

 Thanks 
Please Command.

1 comment:

  1. hi boss thank for posting a blog for Oracle Database Incarnations bcoz in IBM they asking this qtion to many candidate.

    ReplyDelete