How to Change the DBID, DBNAME Using NID Utility (Doc ID 863800.1)
Changing the DBID and Database Name (DB_NAME) :
1. Ensure you have valid cold/hot backup of database. If it's a hot backup (RMAN or OS), ensure you also have all the archived logs and backup of all Online Redo logs (after database is consistently shutdown).
2. export ORACLE_HOME=<Path of the Oracle Home> -- Unix and Linux
set ORACLE_HOME=<Path of the Oracle Home> -- Windows
3. cd <Oracle Home>/bin
4. Drop the dbconsole :
Refer to the following note for more information:
Note.278100.1 How To Drop, Create And Recreate DB Control In A 10g Database.
5. Bring the database to the Mount stage:
SQL> STARTUP MOUNT
6. If you need to use TNS to connect to database, make sure that you have DB_OLD specified in the tnsnames.ora and listener is started.
You can also check if you able to connect to the database using sqlplus :
$ sqlplus sys/<password>@DB_OLD
7. Issue following command to invoke NID utility:
or
$ nid TARGET=SYS/password DBNAME=DB_NEW
The following is an example of what the output for this would look like:
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to database TSTNID2 (DBID=729333573)
Connected to server version 10.2.0
Control Files in database:
D:ORACLEORADATADB102NEWCONTROL01.CTL
D:ORACLEORADATADB102NEWCONTROL02.CTL
D:ORACLEORADATADB102NEWCONTROL03.CTL
Change database ID and database name TSTNID2 to TSTNID3? (Y/[N]) => Y
Proceeding with operation
Changing database ID from 729333573 to 2473929266
Changing database name from DB_OLD to DB_NEW
Control File D:ORACLEORADATADB102NEWCONTROL01.CTL - modified
Control File D:ORACLEORADATADB102NEWCONTROL02.CTL - modified
Control File D:ORACLEORADATADB102NEWCONTROL03.CTL - modified
Datafile D:ORACLEORADATADB102NEWSYSTEM01.DBF - dbid changed, wrote new name
Datafile D:ORACLEORADATADB102NEWUNDOTBS01.DBF - dbid changed, wrote new name
Datafile D:ORACLEORADATADB102NEWSYSAUX01.DBF - dbid changed, wrote new name
Datafile D:ORACLEORADATADB102NEWUSERS01.DBF - dbid changed, wrote new name
Datafile D:ORACLEORADATADB102NEWEXAMPLE01.DBF - dbid changed, wrote new name
Datafile D:ORACLEORADATADB102NEWTEST.DBF - dbid changed, wrote new name
Datafile D:ORACLEORADATADB102NEWTEMP01.DBF - dbid changed, wrote new name
Datafile D:ORACLEORADATADB102NEWTEMP011.DBF - dbid changed, wrote new name
Control File D:ORACLEORADATADB102NEWCONTROL01.CTL - dbid changed, wrote new name
Control File D:ORACLEORADATADB102NEWCONTROL02.CTL - dbid changed, wrote new name
Control File D:ORACLEORADATADB102NEWCONTROL03.CTL - dbid changed, wrote new name
Instance shut down
Database name changed to DB_NEW.
Modify parameter file and generate a new password file before restarting.
Database ID for database DB_NEW changed to 2473929266.
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.
8. Change the DB_NAME in the pfile/spfile:
Set the DB_NAME initialization parameter in the initialization parameter file (PFILE) to the new
database name.
9. If you are using ASM and want to change the file name, follow this Article at this point
10. NID Utility will shutdown the database after the execution. So mount the database once again.
SQL> STARTUP MOUNT
11. Open the database in RESETLOGS mode:
SQL> ALTER DATABASE OPEN RESETLOGS;
12. Recreate the password file since the DB NAME has been changed:
where
file - name of password file (mand),
password - password for SYS (mand),
entries - maximum number of distinct DBA,
force - whether to overwrite existing file (opt),
nosysdba - whether to shut out the SYSDBA logon (opt for Database Vault only).
Note: There are no spaces around the equal-to (=) character.
On Unix/Linux the passwordfile convention is : $ORACLE_HOME/dbs/orapw$ORACLE_SID
On MS Windows the passwordfile convention is : %ORACLE_HOME%databasePWD%ORACLE_SID%.ORA
13. Change the $ORACLE_HOME/network/admin/tnsnames.ora file wherever it has the old db name.
14. If there is a static registration of the database in the listener.ora file then change the database name in the following file $ORACLE_HOME/network/admin/listener.ora.
15. Change of Global Database Names:
If you are dealing with a database in a distributed database system, then each database should have a unique global database name. The DBNEWID utility does not change global database names. This can only be done with the SQL ALTER DATABASE statement, for which the syntax is as follows:
The global database name is made up of a database name and a domain, which are determined by the DB_NAME and DB_DOMAIN initialization parameters when the database is first created.
Windows specific steps:
16. Recreate the Database Service :
17. Recreate the DB Console service :
This command will ask you the new SID and will delete and recreate the service.
Refer to the following note for more information:
Note.278100.1 How To Drop, Create And Recreate DB Control In A 10g Database
Changing Only the Database ID
1-6 except 4. Follow the steps 1 to 6 (except step 4) given in above section.
7. Issue following command to invoke the NID utility:
or
$ nid TARGET=SYS/password
8. NID Utility will shutdown the database after the execution. So mount the database once again.
SQL> STARTUP MOUNT
9. Open the database in RESETLOGS mode:
SQL> ALTER DATABASE OPEN RESETLOGS;
Changing Only the Database Name
1-6. Follow the steps 1 to 6 given in first section.
7. Invoke the NID utility using following command
You must specify both the DBNAME and SETNAME parameters.
or
$ nid TARGET=SYS/password DBNAME=test_db SETNAME=YES
8. Change the DB_NAME in the pfile/spfile: Follow step 8 from the first section.
9. If you are using ASM and want to change the file name, follow this Article at this point
10. Start up the database in normal mode.
SQL> STARTUP mount
11 - 16 Follow steps 11 to 16 given in the first section as applicable.
Logs for NID :
The operation performed by NID is recorded in the alert file:
For example:
DBNAME will be changed from PROD to new DBNAME of TEST_DB
Starting datafile conversion
Datafile conversion complete
Database name changed to TEST_DB.
Modify parameter file and generate a new password file before restarting.
Successfully changed database name.
*** DBNEWID utility finished successfully ***