The following steps describe how to change the DBID of a database. Optionally, you can change the database name as well.
SHUTDOWN IMMEDIATE STARTUP MOUNT
TARGET
) that has the SYSDBA
privilege (you will be prompted for a password):
% nid TARGET=SYS
To change the database name in addition to the DBID, also specify the DBNAME
parameter on the command line (you will be prompted for a password). The following example changes the database name to test_db
:
% nid TARGET=SYS DBNAME=test_db
The DBNEWID utility performs validations in the headers of the data files 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 data file, including offline normal and read-only data files, shuts down the database, and then exits. The following is an example of what the output for this would look like:
. . . Connected to database PROD (DBID=86997811) . . . Control Files in database: /oracle/TEST_DB/data/cf1.dbf /oracle/TEST_DB/data/cf2.dbf The following datafiles are offline clean: /oracle/TEST_DB/data/tbs_61.dbf (23) /oracle/TEST_DB/data/tbs_62.dbf (24) /oracle/TEST_DB/data/temp3.dbf (3) These files must be writable by this utility. The following datafiles are read-only: /oracle/TEST_DB/data/tbs_51.dbf (15) /oracle/TEST_DB/data/tbs_52.dbf (16) /oracle/TEST_DB/data/tbs_53.dbf (22) These files must be writable by this utility. Changing database ID from 86997811 to 1250654267 Changing database name from PROD to TEST_DB Control File /oracle/TEST_DB/data/cf1.dbf - modified Control File /oracle/TEST_DB/data/cf2.dbf - modified Datafile /oracle/TEST_DB/data/tbs_01.dbf - dbid changed, wrote new name Datafile /oracle/TEST_DB/data/tbs_ax1.dbf - dbid changed, wrote new name Datafile /oracle/TEST_DB/data/tbs_02.dbf - dbid changed, wrote new name Datafile /oracle/TEST_DB/data/tbs_11.dbf - dbid changed, wrote new name Datafile /oracle/TEST_DB/data/tbs_12.dbf - dbid changed, wrote new name Datafile /oracle/TEST_DB/data/temp1.dbf - dbid changed, wrote new name Control File /oracle/TEST_DB/data/cf1.dbf - dbid changed, wrote new name Control File /oracle/TEST_DB/data/cf2.dbf - dbid changed, wrote new name Instance shut down Database name changed to TEST_DB. Modify parameter file and generate a new password file before restarting. Database ID for database TEST_DB changed to 1250654267. All previous backups and archived redo logs for this database are unusable. Database has been shutdown, open database with RESETLOGS option. Successfully changed database name and ID. DBNEWID - Completed successfully.
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.
. . . Connected to database PROD (DBID=86997811) . . . Control Files in database: /oracle/TEST_DB/data/cf1.dbf /oracle/TEST_DB/data/cf2.dbf The following datafiles are offline clean: /oracle/TEST_DB/data/tbs_61.dbf (23) /oracle/TEST_DB/data/tbs_62.dbf (24) /oracle/TEST_DB/data/temp3.dbf (3) These files must be writable by this utility. The following datafiles are read-only: /oracle/TEST_DB/data/tbs_51.dbf (15) /oracle/TEST_DB/data/tbs_52.dbf (16) /oracle/TEST_DB/data/tbs_53.dbf (22) These files must be writable by this utility. The following datafiles are offline immediate: /oracle/TEST_DB/data/tbs_71.dbf (25) /oracle/TEST_DB/data/tbs_72.dbf (26) NID-00122: Database should have no offline immediate datafiles Change of database name failed during validation - database is intact. DBNEWID - Completed with validation errors.
STARTUP MOUNT
RESETLOGS
mode and resume normal use. For example:
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.