Hello everyone, today we are going to understand how to rename an Oracle Database using the NID utility. This is a standard Oracle-provided command-line tool available in the Oracle binaries.
NID updates the database name and DBID by modifying headers of datafiles, control files, and internal metadata. Manual updates like init.ora changes and SPFILE recreation are still required.
Rename an Oracle Database
The NID command changes the database name (DB_NAME) and DBID. It updates control files, datafile headers, and other internal structures. After this process, you must manually adjust parameter files and recreate SPFILE if needed.
Step 1: Stop the Database Cleanly
A clean shutdown is recommended before renaming. Perform checkpoint and log switch to ensure database consistency. Avoid using ABORT unless absolutely required.
[oracle@ndcrandb admin]$ echo $ORACLE_SID PBITEST [oracle@ndcrandb admin]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Mon Feb 10 13:37:36 2025 Copyright (c) 1982, 2013, Oracle. All rights reserved. SQL> alter system switch logfile; System altered. SQL> alter system switch logfile System altered. SQL> alter system checkpoint; System altered. SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down.
Step 2: Start Database in MOUNT Mode
The database must be in MOUNT state for the NID operation.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 1152450560 bytes
Fixed Size 2252584 bytes
Variable Size 352321752 bytes
Database Buffers 788529152 bytes
Redo Buffers 9347072 bytes
Database mounted.
Step 3: Create PFILE and Update DB Name
Generate a PFILE from SPFILE and modify the db_name parameter with the new database name.
SQL> create pfile='/tmp/init_PBITEST_Bkp_100225.ora' from spfile; $ cp /tmp/init_PBITEST_Bkp_100225.ora $ORACLE_HOME/dbs/initNEWPBI.ora $ vi $ORACLE_HOME/dbs/initNEWPBI.ora db_name=NEWPBI
Ensure the new init file reflects the correct DB name. This will be used during restart after renaming.
Step 4: Execute NID Command
Run the NID utility from OS level. It is located under $ORACLE_HOME/bin directory.
[oracle@ndcrandb admin]$export ORACLE_SID=PBITEST [oracle@ndcrandb admin]$nid target=/ dbname=NEWPBI DBNEWID: Release 11.2.0.4.0 - Production on Mon Feb 10 13:40:47 2025 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. Connected to database PBITEST (DBID=2695375495) Connected to server version 11.2.0 Control Files in database: +REDO1/PBITEST/controlfile/current.256.838662091 +REDO2/PBITEST/controlfile/current.256.838662091 Change database ID and database name PBITEST to NEWPBI? (Y/[N]) => Y Proceeding with operation Changing database ID from 2695375495 to 4057109727 Changing database name from PBITEST to NEWPBI Control File +REDO1/PBITEST/controlfile/current.256.838662091 - modified Control File +REDO2/PBITEST/controlfile/current.256.838662091 - modified Datafile +DATA/PBITEST/datafile/system.259.83866210 - dbid changed, wrote new name Datafile +DATA/PBITEST/datafile/sysaux.258.83866210 - dbid changed, wrote new name Datafile +DATA/PBITEST/datafile/undotbs1.257.83866210 - dbid changed, wrote new name Datafile +DATA/PBITEST/datafile/users.260.83866211 - dbid changed, wrote new name Datafile +DATA/PBITEST/datafile/app1tab.267.83873288 - dbid changed, wrote new name Datafile +DATA/PBITEST/datafile/app2.266.83873290 - dbid changed, wrote new name Datafile +DATA/PBITEST/tempfile/temp.256.83866210 - dbid changed, wrote new name Control File +REDO1/PBITEST/controlfile/current.256.838662091 - dbid changed, wrote new name Control File +REDO2/PBITEST/controlfile/current.256.838662091 - dbid changed, wrote new name Instance shut down Database name changed to NEWPBI. Modify parameter file and generate a new password file before restarting. Database ID for database NEWPBI changed to 4057109727. All previous backups and archived redo logs for this database are unusable. Database is not aware of previous backups and archived logs in Recovery Area. Database has been shutdown, open database with RESETLOGS option. Succesfully changed database name and ID. DBNEWID - Completed succesfully.
After NID execution:
• DBID changes
• Old backups become unusable
• RESETLOGS is mandatory
Step 5: Open Database with RESETLOGS
After renaming, restart the database using new SID and open it with RESETLOGS.
[oracle@ndcrandb ~]$export ORACLE_SID=NEWPBI [oracle@ndcrandb admin]$sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Mon Feb 10 13:37:36 2025 Copyright (c) 1982, 2013, Oracle. All rights reserved. SQL> startup mount; ORACLE instance started. Total System Global Area 1152450560 bytes Fixed Size 2252584 bytes Variable Size 352321752 bytes Database Buffers 788529152 bytes Redo Buffers 9347072 bytes Database mounted. SQL> ALTER DATABASE OPEN RESETLOGS; Database opened. SQL> select name from v$database; NAME --------- NEWPBI
Recreate SPFILE
Once database is open, recreate SPFILE from updated PFILE.
SQL> CREATE SPFILE='+DATA' FROM PFILE;
File created.
Important Notes
- Database must be in MOUNT mode before running NID
- Always take full backup before renaming
- Old backups cannot be used after DBID change
- RESETLOGS is mandatory after rename
Key Takeaways
NID is the official Oracle utility for renaming databases.
It updates DB_NAME and DBID internally across all files.
Proper preparation (checkpoint, log switch, clean shutdown) is critical.
Always recreate SPFILE and take fresh backup after rename.
For official documentation, please refer to the following link:
Oracle DBNEWID Utility Documentation
Toufique Khan

No comments:
Post a Comment