Feb 4, 2010

Change database name using DBNEWID utility


Make a whole database backup before changing the database name.

Invoke SQL*Plus and connect as a user with SYSDBA privileges.
          $sqlplus / as sysdba

Issue the following query to determine the current database name:
SQL>SELECT name FROM v$database;

Shut down the instance using the NORMAL, IMMEDIATE, or TRANSACTIONAL.
SQL>SHUTDOWN IMMEDIATE

Start the instance and mount the database.
SQL>STARTUP MOUNT

Invoke the DBNEWID utility on the command line, specifying a valid user with the SYSDBA privilege. You must specify the DBNAME parameter and supply your new database name. You must also specify the YES value for the SETNAME parameter to indicate that only the DBNAME is to be changed. DBNEWID performs validations of the headers of the control files, but not the data files, 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.

$nid TARGET=username/password@alias DBNAME=newdbname SETNAME=YES LOGFILE=db_rename.log

After DBNEWID successfully changes the database name, shut down the instance:

SQL>SHUTDOWN IMMEDIATE

Change the DB_NAME initialization parameter to your new database name.
          $vi init$ORACLE_SID.ora
          $DB_NAME=new_db_name

Create a new password file using the ORAPWD utility:

$orapwd file=orapw password= entries=

Start the instance and open the database:
SQL>STARTUP

Verify the change to the database name by issuing the following query:
SQL>SELECT name FROM v$database;

We can check the options used for DBNEWID from below command
          $nid help=y

No comments:

Post a Comment

Search This Blog