You are on page 1of 3

Changing The database Name:

---------------------------

Description:
------------
In oracle 10g its possible to change the database name by using DBNEWID utility.

Scenerio:
---------
Now we are going to change the database name from "doyen" to "doyen1".

Note:
-----
Before doing this take the whole database backup.

Steps to change the database name:


----------------------------------
1.If you have multiple instances running on the same server its good to set sid
first.
In linux:
---------
$export ORACLE_SID=doyen
In Windows:
-----------
set ORACLE_SID=doyen

2.Connecting to sqlplus and shutdown the database which we are going to change the
database name
sql>shutdown immediate

3.Put the database in mount stage


sql>startup mount

4.Exit from the sql prompt by typing exit


sql>exit

5.Invoke the DBNEWID utility(nid) specifying the new database name from the
command prompt using user with sysdba privilege
$ nid target=sys/oracle dbname=doyen1 setname=yes

6.DBNEWID performs validations in the headers of the control files (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,
shuts down the database and exits.

7.Log file:
-----------
DBNEWID: Release 10.2.0.1.0 - Production on Thu Aug 28 10:21:42 2008

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

Connected to database DOYEN (DBID=1998825041)

Connected to server version 10.2.0

Control Files in database:


/u01/app/oracle/oradata/doyen/ctl1.dbf
Change database name of database DOYEN to DOYEN1? (Y/[N]) => y

Proceeding with operation


Changing database name from DOYEN to DOYEN1
Control File /u01/app/oracle/oradata/doyen/ctl1.dbf - modified
Datafile /u01/app/oracle/oradata/doyen/system01.dbf - wrote new name
Datafile /u01/app/oracle/oradata/doyen/undotbs01.dbf - wrote new name
Datafile /u01/app/oracle/oradata/doyen/sysaux.dbf - wrote new name
Datafile /u01/app/oracle/oradata/doyen/users.dbf - wrote new name
Datafile /u01/app/oracle/oradata/doyen/welcome.dbf - wrote new name
Datafile /u01/app/oracle/oradata/doyen/example.dbf - wrote new name
Datafile /u01/app/oracle/oradata/doyen/temp01.dbf - wrote new name
Control File /u01/app/oracle/oradata/doyen/ctl1.dbf - wrote new name
Instance shut down

Database name changed to DOYEN1.


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

8.Now the database in shutdown state.Put the database in mount state.


It will not come to mount stage.It throws some error.
SQL> startup mount
ORACLE instance started.

Total System Global Area 583008256 bytes


Fixed Size 1220676 bytes
Variable Size 159387580 bytes
Database Buffers 415236096 bytes
Redo Buffers 7163904 bytes
ORA-01103: database name 'DOYEN1' in control file is not 'DOYEN'

9.change the database name in spfile.By issuing this command.


sql>alter system set db_name=doyen1 scope=spfile;
system altered

If we use pfile to startup go to that location open it as a text editor and change
the database name manually.

Pfile location-->$ORACLE_HOME/dbs/init$ORACLE_SID.ora

10.Create new password file.Password file location is


$ORACLE_HOME/dbs/orapw$ORACLE_SID.

11.shutdown and startup your database.


sql>startup force

12.Check the database name.


sql>show parameter db_name
NAME TYPE VALUE
------------------------------------ -----------
------------------------------
db_name string DOYEN1

13.Now the database name has been changed.

14.Reference: http://sabdarsyed.blogspot.com/2007/03/changing-oracle-database-
name-in-oracle.html

You might also like