Oracle Database
How to change Oracle Database Name
In this topic we will see how can we change our database name using Oracle NID tool. Use the syntax bellow to change the Dtabase Name. Make sure you shutdown and start up in mount mode your oracle database before.
SQL> shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 1610612736 bytes
Fixed Size 2077904 bytes
Variable Size 385878832 bytes
Database Buffers 1207959552 bytes
Redo Buffers 14696448 bytes
Database mounted.
SQL> exit
$ nid TARGET=SYS/Password DBNAME=NEWDB SETNAME=YES
DBNEWID: Release 11.2.0.4.0
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to database TEST (DBID=2127904120)
Connected to server version 11.2.0
Control Files in database:
/uu1/oracle/oradata/ABUZERDB/control01.ctl
/u01/oracle/flash_recovery_area/control02.ctl
Change database name of database TEST to NEWDB? (Y/[N]) => Y
Proceeding with operation
Changing database name from TEST to NEWDB
Control File /uu1/oracle/oradata/ABUZERDB/control01.ctl - modified
Control File /u01/oracle/flash_recovery_area/control02.ctl - modified
Datafile /uu1/oracle/oradata/ABUZERDB/system01.db - wrote new name
Datafile /uu1/oracle/oradata/ABUZERDB/sysaux01.db - wrote new name
Datafile /uu1/oracle/oradata/ABUZERDB/undotbs01.db - wrote new name
Datafile /uu1/oracle/oradata/ABUZERDB/users01.db - wrote new name
Datafile /uu1/oracle/oradata/ABUZERDB/temp01.db - wrote new name
Control File /uu1/oracle/oradata/ABUZERDB/control01.ctl - wrote new name
Control File /u01/oracle/flash_recovery_area/control02.ctl/control02.ctl - wrote new name
Instance shut down
Database name changed to NEWDB.
Modify parameter file and generate a new password file before restarting.
Succesfully changed database name.
DBNEWID - Completed succesfully.
2. Recreate the new password file.
$ orapwd file=/u01/oracle/product/11.2.0/dbhome_1/dbs/passwd.ora password=Password entries=5
3. Make sure that you drop any password files before or you will get some errors. Rename the init.ora file.
$ rename init.ora initDB.ora
4. Edit the initDB.ora parameters file.
$ vi initDB.ora
# Change '<oracle_BASE>' to point to the oracle base (the one you specify at
# install time)
db_name='NEWDB'
5. Now start the database in nomount mode and alter the db_name parameter in the control file.
$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 417546240 bytes
Fixed Size 2213936 bytes
Variable Size 289408976 bytes
Database Buffers 121634816 bytes
Redo Buffers 4288512 bytes
SQL> alter system set db_name=NEWDB scope=spfile;
System altered.
5. Shutdown the database and start it backup.
SQL> shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.
Total System Global Area 417546240 bytes
Fixed Size 2213936 bytes
Variable Size 268437456 bytes
Database Buffers 142606336 bytes
Redo Buffers 4288512 bytes
Database mounted.
Database opened
6. Check the status and name of you database.
SQL> select status from v$instance;
STATUS
------------
OPEN
SQL> select * from global_name;
GLOBAL_NAME
--------------------------------------------------------------------------------
NEWDB