Friday, November 14, 2008

Change Database Name and ID

Changing the DBID and Database Name is possible since version 9.2.0.

The following steps describe how to change the DBID of a database. Optionally, you can change the database name as well.
1. Ensure that you have a recoverable whole database backup.
2. Ensure that the target database is mounted but not open, and that it was shut down consistently prior to mounting.
For example:
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;

3. Invoke the DBNEWID utility on the command line, specifying a valid user with the SYSDBA privilege.
For example:
nid TARGET=SYS/oracle@test_db

To change the database name in addition to the DBID, specify the DBNAME parameter. This example changes the name to test_db2:
nid TARGET=SYS/oracle@test DBNAME=test_db2

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 for each datafile (including offline normal and read-only datafiles), and then exits. The database is left mounted but is not yet usable.
For example:
DBNEWID: Release 9.2.0.1.0
(c) Copyright 2002 Oracle Corporation. All rights reserved.
Connected to database TEST_DB (DBID=3942195360)
Control Files in database:
/oracle/dbs/cf1.f
/oracle/dbs/cf2.f
Change database id of database SOLARIS? (Y/[N]) => y
Proceeding with operation
Datafile oracle/dbs/tbs_01.f - changed
Datafile /oracle/dbs/tbs_02.f - changed
Datafile /oracle/dbs/tbs_11.f - changed
Datafile /oracle/dbs/tbs_12.f - changed
Datafile /oracle/dbs/tbs_21.f - changed
New DBID for database TEST_DB is 3942196782.
All previous backups and archived redo logs for this database are unusable
Proceed to shutdown database and open with RESETLOGS option.
DBNEWID - Database changed.

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

4. After DBNEWID successfully changes the DBID, shut down the database:

SHUTDOWN IMMEDIATE;

5. Mount the database. For example:
STARTUP MOUNT

6. Open the database in 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.

Changing Only the Database Name

The following steps describe how to change the database name without changing the DBID.
1. Ensure that you have a recoverable whole database backup.
2. Ensure that the target database is mounted but not open, and that it was shut down
consistently prior to mounting. For example:
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;

3. Invoke the utility on the command line, specifying a valid user with the SYSDBA privilege. You must specify both the DBNAME and SETNAME parameters. This example changes the name to test_db2:
nid TARGET=SYS/oracle@test_db DBNAME=test_db2 SETNAME=YES

DBNEWID performs validations in the headers of the control files (not the datafiles) before attempting I/O to the files. If validation is successful, then DBNEWID prompts for confirmation, changes the database name in the control files, and exits. After DBNEWID completes successfully, the database is left mounted but is not yet usable.
DBNEWID: Release 9.2.0.1.0
(c) Copyright 2002 Oracle Corporation. All rights reserved.
Connected to database TEST_DB (DBID=3942196782)
Control Files in database:
/oracle/dbs/cf1.f
/oracle/dbs/cf2.f
Change database name of database TEST_DB to TEST_DB2? (Y/[N]) => Y

Proceeding with operation


Database name changed from TEST_DB to TEST_DB2 - database needs to be shutdown.

Modify parameter file and generate a new password file before restarting.
DBNEWID - Successfully changed database name

If validation is not successful, then DBNEWID terminates and leaves the target database intact. You can open the database, fix the error, and then either resume the DBNEWID operation or continue using the database without changing the database name.
4. Shut down the database. For example:
SHUTDOWN IMMEDIATE;

5. Set the DB_NAME initialization parameter in the initialization parameter file to the new database name.
6. Create a new password file.
7. Start up the database and resume normal use. For example:
STARTUP;

Reference: http://download.oracle.com/docs/cd/B10500_01/server.920/a96652/ch14.htm

No comments:

Post a Comment

comment