This lesson discusses why you might need to issue the reset database command and the syntax to do so.
Let us say your database failed and was recovered at some point in time. As a result, you may have performed an incomplete recovery of your database and would have issued an alter database open resetlogs command. In this case, Recovery Manager cannot distinguish between your resetlogs[1] command and an inadvertent recovery of an old control file. In both cases, Recovery Manager knows that something is not right with your database. Thus, the reset database command will create a new incarnation record of your target database.
The syntax for this is:
RMAN>reset database
Incarnation Number and the RESET DATABASE Command in Oracle 19c
In Oracle 19c, the incarnation number plays a critical role in recovery and backup management using RMAN (Recovery Manager). When a database is opened with RESETLOGS, Oracle assigns a new incarnation number to distinguish the current history from the past database history.
What is the Incarnation Number?
The incarnation number represents a unique identity for a specific timeline of the database.
When a database undergoes RESETLOGS, a new incarnation is generated.
Oracle keeps track of all database incarnations in the control file and RMAN catalog.
When is RESETLOGS Used?
After incomplete recovery (point-in-time recovery).
After using RMAN DUPLICATE to clone a database.
After restoring a backup that is not part of the current incarnation.
When opening a newly recovered control file.
How to View Database Incarnations?
You can list all database incarnations using RMAN:
RMAN> LIST INCARNATION OF DATABASE;
Sample output:
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------- ---------- ---------- ---------------
1 2 ORCL 1234567890 CURRENT 2456789 10-JAN-2025
1 1 ORCL 1234567890 PARENT 1000000 01-JAN-2025
The CURRENT incarnation is the active one.
The PARENT incarnation represents the previous timeline before a RESETLOGS operation.
How to Change to an Older Incarnation?
To recover to an earlier incarnation (e.g., before a RESETLOGS), use:
RMAN> RESET DATABASE TO INCARNATION ;
Example:
RMAN> RESET DATABASE TO INCARNATION 1;
This tells RMAN to use backups from the older incarnation for recovery.
Performing Basic Maintenance with RESET DATABASE
If a reset logs operation was done mistakenly, and you need to restore a previous incarnation:
Identify the required incarnation with LIST INCARNATION OF DATABASE;
Reset the database to that incarnation using RESET DATABASE TO INCARNATION <ID>;
Restore and recover the database from the appropriate backups.
If a new incarnation was created but causes restore/recovery issues, you may need to switch back to a previous incarnation.
Resetting the Database in Emergency Scenarios
When control files are lost and recreated, the database needs a RESETLOGS operation, which creates a new incarnation.
Before cloning a database, you may need to reset the incarnation number to use the correct backups.
Key Takeaways
The incarnation number helps track different database timelines after RESETLOGS.
Use LIST INCARNATION to view previous and current incarnations.
Use RESET DATABASE TO INCARNATION <number> to recover from an earlier timeline.
RMAN ensures backups from the correct incarnation are used for recovery.
The incarnation number[2] is used to identify a version of the target database. This version number ensures that the correct archived and online redo log files are applied during a recovery of your target database.
Reset Database to incarnation
If you issue the list incarnations command, you will get a list of all incarnation records for your database.
One incarnation will be current, the others will not. Review the table below to check if you have the following output from a list incarnation of databasecommand:
DB KEY
INC KEY
DBNAME
DBID
CURR
1
10
ORACLE
1234567890
NO
1
100
ORACLE
1234567890
NO
1
1000
ORACLE
1234567890
YES
If it turns out that you have received any of the outputs indicated in the table, you can perform a reset command to restore the database back to version 10 by issuing the following command:
RMAN>reset database to incarnation 10
You will subsequently need to issue the appropriate restore and recover RMAN commands to recover the correct database files from incarnation 10. The following graphic demonstrates the output from resetting your client's database, (orc2), to incarnation 1119, which is also the current incarnation.
Reset database to incarnation 1119;
DB Key
Inc Key
DB Name
DB ID
STATUS
Reset SCN
Reset Time
1
2
TRGT
1224038686
PARENT
1
2-Jul-02
1
582
TRGT
1224038686
CURRENT
59727
10-Jul-02
Reset Oracle Database
The following section discusses how to reset a database to a specific incarnation.
Steps to reset the Database to a specific incarnation
The steps in the simulation are as follows:
Enter the command to determine the RMAN-supported incarnations of your databases. Type list incarnation of database at the prompt and press enter.
Enter the command to reset the database ORC1, which is the database you are attached to, to its previous incarnation. Type reset database to incarnation 4 at the prompt and press enter.
This completes the simulation.
Resetting the Database Incarnation in the Recovery Catalog
You create an incarnation of the database when you open the database with the RESETLOGS option. You can access a record of the new incarnation in the V$DATABASE_INCARNATION view. If you open the database with the RESETLOGS option, then a new database incarnation record is automatically created in the recovery catalog. The database also implicitly and automatically issues a RESET DATABASE command,
which specifies that this new incarnation of the database is the current incarnation. All subsequent backups and log archiving done by the target database is associated with the new database incarnation. Whenever RMAN returns the database to an SCN before the current RESETLOGS SCN, using either RESTORE and RECOVER or FLASHBACK DATABASE, the RESET DATABASE TO
INCARNATION command is required. However, you do not need to execute RESET DATABASE TO INCARNATION explicitly in the following scenarios because RMAN runs the command implicitly with Flashback.
You use FLASHBACK DATABASE to rewind the database to an SCN in the direct ancestral path (see "Database Incarnations" on page 14-6 for an explanation of the direct ancestral path).
You use FLASHBACK DATABASE to rewind the database to a restore point. The following procedure explains how to reset the database incarnation when recovering through a RESETLOGS.
To reset the recovery catalog to an older incarnation for media recovery:
Determine the incarnation key of the desired database incarnation. Obtain the incarnation key value by issuing a LIST command:
LIST INCARNATION OF DATABASE trgt;
Generate and output the tabular data which appears in the image.
The incarnation key is listed in the Inc Key column.
Reset the database to the old incarnation. For example, enter: RESET DATABASE TO INCARNATION 2;
If the control file of the previous incarnation is available and mounted, then skip to Step 6 of this procedure. Otherwise, shut down the database and start it without mounting.
For example:
SHUTDOWN IMMEDIATE
STARTUP NOMOUNT
Restore a control file from the old incarnation. If you have a control file tagged, then specify the tag. Otherwise, you can run the SET UNTIL command, as in this example:
RUN
{
SET UNTIL 'SYSDATE-45';
RESTORE CONTROLFILE;
# only if current control file is not available
}
Mount the restored control file:
ALTER DATABASE MOUNT;
Run RESTORE and RECOVER commands to restore and recover the database files from the prior incarnation, then open the database with the RESETLOGS option. For example, enter:
RESTORE DATABASE;
RECOVER DATABASE;
ALTER DATABASE OPEN RESETLOGS;
In the next lesson, you will learn how to use RMAN to resynchronize your target database.
[1]resetlogs: Used to reapply the archive log files to your database.
[2]Incarnation number: Unique number that is used to identify a version of the database.