0% found this document useful (0 votes)
117 views7 pages

How To Change The DBID, DBNAME Using NID Utility (Doc ID 863800.1)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
117 views7 pages

How To Change The DBID, DBNAME Using NID Utility (Doc ID 863800.1)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

4/23/24, 4:39 PM Document 863800.

1
Copyright (c) 2024, Oracle. All rights reserved. Oracle Confidential.

How to Change the DBID, DBNAME Using NID Utility (Doc ID 863800.1)

In this Document

Goal
Solution
Changing the DBID and Database Name (DB_NAME)
Changing Only the Database ID
Changing Only the Database Name
Logs for NID :
References

APPLIES TO:

Oracle Database - Enterprise Edition - Version 10.2.0.1 and later


Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Express Cloud Service - Version N/A and later
Gen 1 Exadata Cloud at Customer (Oracle Exadata Database Cloud Machine) - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Information in this document applies to any platform.

GOAL

The goal of this note is to describe how to change DBID AND/OR DB_NAME of a database.

Note:

Changing the DBID of a database is a serious procedure.


When the DBID of a database is changed, all previous backups and archived logs of the database become unusable. This is similar to creating a database except
that the data is already in the datafiles. After you change the DBID, backups and archive logs that were created prior to the change can no longer be used because
they still have the original DBID, which does not match the current DBID. You must open the database with the RESETLOGS option, which re-creates the online redo
logs and resets their sequence to 1 (see the Oracle Database Administrator's Guide). Consequently, you should make a backup of the whole database immediately
after changing the DBID.

If you change DBID at Primary in a Standby Environment, the STANDBY Database must be rebuild.
Without Standby recreated, you will see messages like this example in Alert.log:
.
Standby database ID mismatch [0x80a847ae:0x396b3b92] (2158512046:963328914)

https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=8yfbnhqfm_102&id=863800.1 1/7
4/23/24, 4:39 PM Document 863800.1
Mon Apr 07 12:18:26 2014
Standby database ID mismatch [0x80a847ae:0x396b3b92] (2158512046:963328914)
.

Changing the DBNAME without changing the DBID does not require you to open with the RESETLOGS option, so database backups and archived logs are not
invalidated. However, changing the DBNAME does have consequences. You must change the DB_NAME initialization parameter after a database name change to
reflect the new name. Also, you may have to re-create the Oracle password file. If you restore an old backup of the control file (before the name change), then you
should use the initialization parameter file and password file from before the database name change.

For RAC Databases, ensure that you shutdown all instances, start only one instance with CLUSTER_DATABASE=FALSE and perform below activities. After the activity is
performed, start all rac instances normally.

This procedure can also be executed to change the name of a container database.

SOLUTION

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

https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=8yfbnhqfm_102&id=863800.1 2/7
4/23/24, 4:39 PM Document 863800.1

7. Issue following command to invoke NID utility:

$ nid TARGET=SYS/<password>@<service> DBNAME=<NEW DB name>

or

$ nid TARGET=SYS/<password> DBNAME=<NEW DB name>

The DBNEWID utility performs validations in the headers of the datafiles and control files before attempting I/O to the files. If validation is successful, then
DBNEWID prompts you to confirm the operation (unless you specify a log file, in which case it does not prompt), changes the DBID (and the DBNAME, if specified,
as in this example) for each datafile, including offline normal and read-only datafiles, shuts down the database, and then exits.

The following is an example of what the output for this would look like:

DBNEWID: Release 10.2.0.4.0 - Production on Mon Jul 27 18:29:06 2009

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to database <OLD DB Name> (DBID=729333573)

Connected to server version 10.2.0

Control Files in database:


D<PATH>\CONTROL01.CTL
D<PATH>\CONTROL02.CTL
D<PATH>\CONTROL03.CTL

Change database ID and database name <OLD DB Name> to <NEW DB Name>? (Y/[N]) => Y

Proceeding with operation


Changing database ID from 729333573 to 2473929266
Changing database name from <OLD DB Name> to <NEW DB Name>
Control File D:<PATH>\CONTROL01.CTL - modified
Control File D:<PATH>\CONTROL02.CTL - modified
Control File D:<PATH>\CONTROL03.CTL - modified

Datafile D:<PATH>\SYSTEM01.DBF - dbid changed, wrote new name


Datafile D:<PATH>\UNDOTBS01.DBF - dbid changed, wrote new name
Datafile D:<PATH>\SYSAUX01.DBF - dbid changed, wrote new name
Datafile D:<PATH>\USERS01.DBF - dbid changed, wrote new name
Datafile D:<PATH>\EXAMPLE01.DBF - dbid changed, wrote new name
Datafile D:<PATH>\TEST.DBF - dbid changed, wrote new name
Datafile D:<PATH>\TEMP01.DBF - dbid changed, wrote new name
Datafile D:<PATH>\TEMP011.DBF - dbid changed, wrote new name
Control File D:<PATH>\CONTROL01.CTL - dbid changed, wrote new name
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=8yfbnhqfm_102&id=863800.1 3/7
4/23/24, 4:39 PM Document 863800.1
Control File D:<PATH>\CONTROL02.CTL - dbid changed, wrote new name
Control File D:<PATH>\CONTROL03.CTL - dbid changed, wrote new name

Instance shut down

Database name changed to <NEW DB Name>


Modify parameter file and generate a new password file before restarting.
Database ID for database <NEW DB Name> 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.

If validation is not successful, then DBNEWID terminates and leaves the target database intact, as shown in the following sample output. You can open the
database, fix the error, and then either resume the DBNEWID operation or continue using the database without changing its DBID.

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.

The NID utility does not change the server parameter file (SPFILE). Therefore, if you use SPFILE to start your Oracle database, you must re-create the initialization
parameter file from the server parameter file, remove the server parameter file, change the DB_NAME in the initialization parameter file, and then re-create the
server parameter file.

9. If you are using ASM and want to change the file name, follow this Article at this point

Note 564993.1 How to rename/move a datafile in the same ASM diskgroup

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;

Make a new database backup. Because you reset the online redo logs, the old backups and archived logs are no longer usable in the current incarnation of the
database.

https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=8yfbnhqfm_102&id=863800.1 4/7
4/23/24, 4:39 PM Document 863800.1

12. Recreate the password file since the DB NAME has been changed:

$ orapwd file=<fname> password=<password> entries=<users> force=<y/n> nosysdba=<y/n>

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%\database\PWD<%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:

ALTER DATABASE RENAME GLOBAL_NAME TO <newname>.<domain>;

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 :

$ oradim -NEW -SID prod -STARTMODE auto -PFILE <....\init<NEW Oracle_Sid>.ora>

17. Recreate the DB Console service :

$ emca -config dbcontrol db -repos recreate

This command will ask you the new SID and will delete and recreate the service.

https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=8yfbnhqfm_102&id=863800.1 5/7
4/23/24, 4:39 PM Document 863800.1

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:

$ nid TARGET=SYS/<password>@<service>

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;

Make a new database backup. Because you reset the online redo logs, the old backups and archived logs are no longer usable in the current incarnation of the
database.

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.

$ nid TARGET=SYS/<password>@<service> DBNAME=<NEW DB Name> SETNAME=YES

or

$ nid TARGET=SYS/<password> DBNAME=<NEW DB Name> 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

https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=8yfbnhqfm_102&id=863800.1 6/7
4/23/24, 4:39 PM Document 863800.1

Note 564993.1 How to rename/move a datafile in the same ASM diskgroup

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:

*** DBNEWID utility started ***


DBNAME will be changed from <OLD DB Name> to new DBNAME of <NEW DB Name>
Starting datafile conversion
Datafile conversion complete
Database name changed to <NEW database name>.
Modify parameter file and generate a new password file before restarting.
Successfully changed database name.
*** DBNEWID utility finished successfully ***

REFERENCES

NOTE:15390.1 - How to Rename Database/Change DB_NAME or ORACLE_SID/Instance Name


NOTE:278100.1 - How To Drop, Create And Recreate Database Control (dbconsole) Web Site in Releases 10g and 11g
Didn't find what you are looking for?

https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-state=8yfbnhqfm_102&id=863800.1 7/7

You might also like