Series: Duplicating an Oracle Database – Part 3: Renaming the Duplicated Database

In the final part of this series, we will rename the duplicated Oracle database. After duplicating a database, renaming it is crucial to avoid conflicts with the original source database.

Step 1: Shut Down the Database on the Destination Server

First, shut down the database on the destination server.

SQL> shutdown immediate;

Step 2: Start the Database in NOMOUNT Mode

Next, start the database in NOMOUNT mode using the modified PFILE.

SQL> startup nomount pfile='/u01/app/oracle/product/19.0.0/db_1/dbs/initorcl.ora';
SQL> alter database mount;

Step 3: Rename the Database Using the NID Utility

Use the nid (DBNEWID) utility to rename the duplicated database.

nid target=sys/password dbname=test

Step 4: Modify the Parameter File

Edit the parameter file to reflect the new database name.

vi /u01/app/oracle/product/19.0.0/db_1/dbs/initorcl.ora

Change the db_name parameter to the new name:

*.db_name='test'

Step 5: Create a New Password File

Create a new password file for the renamed database.

cd /u01/app/oracle/product/19.0.0/db_1/dbs
orapwd file=orapwtest password=<password> entries=10

Step 6: Start the Database and Open with RESETLOGS

The RESETLOGS option is used after renaming or restoring the database because it creates a new incarnation of the database. This is necessary to reset the online redo logs and avoid conflicts with previous log history, ensuring the integrity of the database’s new identity. It effectively marks the start of a fresh timeline for the database, allowing it to continue normal operations without referencing any outdated log sequences.

Finally, start the database and open it using RESETLOGS:

SQL> startup mount;
SQL> alter database open resetlogs;

Step 7: Verify the Status of the New Database

Confirm that the database has been renamed and is running properly.

SQL> select instance_name, status from v$instance;
SQL> select open_mode, name, created from v$database;

Conclusion

In this last part of the series, we have successfully renamed the duplicated Oracle 19c database. You now have a fully functioning duplicate of your production database under a new name, ready for use in development, testing, or other non-production environments.

Leave a Reply

Your email address will not be published. Required fields are marked *