Oracle DBNEWID change DBID
* Backup the database.
* Mount the database after a clean shutdown:
SHUTDOWN IMMEDIATE
STARTUP MOUNT
* Invoke the DBNEWID utility (nid) specifying the new DBNAME from the command line using a user with SYSDBA privilege:
nid TARGET=sys/password@currentdatabase DBNAME=newdatabase
Assuming the validation is successful the utility prompts for confirmation before performing the actions. Typical output may look something like:
$ORACLE_HOME\bin\nid TARGET=sys/password@currentdatabase DBNAME=newdatabase
DBNEWID: Release 9.2.0.3.0 – Production
Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
Connected to database currentdatabase (DBID=1234567890)
Control Files in database:
Change database ID and database name TSH1 to TSH2? (Y/[N]) => Y
Proceeding with operation
Changing database ID from 1234567890 to 1212112121
Changing database name from currentdatabase to newdatabase
Control File
Database name changed to newdatabase.
Modify parameter file and generate a new password file before restarting.
Database ID for database newdatabase changed to 1212112121.
All previous backups and archived redo logs for this database are unusable.
Shut down database and open with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID – Completed succesfully.
* Shutdown the database:
SHUTDOWN IMMEDIATE
* Modify the DB_NAME parameter in the initialization parameter file. The startup will result in an error but proceed anyway.
STARTUP MOUNT
ALTER SYSTEM SET DB_NAME=newdatabase SCOPE=SPFILE;
SHUTDOWN IMMEDIATE
* Create a new password file:
orapwd file=xxx password=password entries=10
* Rename the SPFILE to match the new DBNAME.
* If you are using Windows you must recreate the service so the correct name and parameter file are used:
oradim -delete -sid currentdatabase
oradim -new -sid newdatabase -intpwd password -startmode a -pfile spfilenewdatabase.ora
If you are using UNIX/Linux simply reset the ORACLE_SID environment variable:
ORACLE_SID=newdatabase; export ORACLE_SID
* Alter the listener.ora and tnsnames.ora setting to match the new database name and restart the listener:
lsnrctl reload
* Open the database with RESETLOGS:
STARTUP MOUNT
ALTER DATABASE OPEN RESETLOGS;
* Backup the database.
