In this article we will see how to completely rename an Oracle database and the four different methods to do it.
Method 1
Complete Renaming an Oracle Database
Database Name: troy
Our aim is to change the database name as Hercules.
Database Rename Steps
- Login into troy database, Create the controlfile backup as trace file.
Alter database backup controlfile to trace as /u01/backup/control01.ora; - Shutdown the Database.
Change the init.ora file (like db name, instance name, controlfile path, etc…)
Note: Taken the complete cold backup. (For safer side) - If database running on windows server create the service id using oradim utility.
Oradim new sid Hercules
Set oracle_sid=Hercules - If database running on Unix based server change the oracle_sid in
.bash_profile (Db profile) - Recreate the password file.
- Startup the database in nomount stage using editable pfile.
- Create New Control file
Using backup control file trace to generate the create control file scripts.
Change the Database name, Folder name & files path
Note: Execute the script in sql prompt. Now controlfile created.
CREATE CONTROLFILE REUSE DATABASE “Hercules” RESETLOGS FORCE LOGGING NOARCHIVELOG
MAXLOGFILES 50
MAXLOGMEMBERS 5
MAXDATAFILES 100
MAXINSTANCES 1
MAXLOGHISTORY 453
LOGFILE
GROUP 1 ‘/U01/oradata/Hercules/redo01.log’ SIZE 200M,
GROUP 2 ‘/U01/oradata/Hercules/redo02.log’ SIZE 200M,
GROUP 3 ‘/U01/oradata/Hercules/redo03.log’ SIZE 200M
DATAFILE
‘/U01/oradata/Hercules/system01.dbf’,
‘/U01/oradata/Hercules/undotbs01.dbf’,
‘/U01/oradata/Hercules/users01.dbf’,
CHARACTER SET WE8ISO8859P1;
Note: ( below one is optional otherwise you only change the database name not change a directory path)
Change the directory of datafiles & logfiles path.
create new directory Hercules in ORADATA. Move all the datafiles / logfiles to /U01/oradata/Hercules
/U01/oradata/Troy/ Rename as /U01/oradata/Hercules/ - Now open the database.
Alter database open resetlogs; - Change the Tnsentry, Listener, sqlnet.ora files.
- Taken the complete cold backup
*************************************************************************
Method 2
Change the Oracle Database Name & DBID
Database Name: troy
Our aim is to change the database name as Hercules.
Database & DBID Rename Steps
- Select dbid, name from v$database
- Shutdown the Database.
- Taken the complete cold backup. (Safer side)
- If database running on windows server, create the service id using oradim utility.
- If database running on UNIX based machine, change the oracle_sid name in .bash_profile (profile)
- Create new password file using new database name.
- Change the init parameter (dbname, instance name)
- Startup the database in MOUNT stage using new init parameter.
- Using below statement to change the database name & dbid.
$ NID TARGET=sys/pwd@troy DBNAME=HERCULES
Enter the Y in below prompt.
C:Documents and Settingsraja>nid target=sys/troy@troy dbname=hercules
DBNEWID: Release 10.2.0.1.0 – Production on Wed Feb 18 08:58:22 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to database TROY (DBID=399919941)
Connected to server version 10.2.0
Control Files in database:
E:ORACLEPRODUCT10.2.0ORADATATROYCONTROL01.CTL
E:ORACLEPRODUCT10.2.0ORADATATROYCONTROL02.CTL
E:ORACLEPRODUCT10.2.0ORADATATROYCONTROL03.CTL
Change database ID and database name TROY to HERCULES? (Y/[N]) => y
Proceeding with operation
Changing database ID from 399919941 to 1035501295
Changing database name from TROY to HERCULES
Control File E:ORACLEPRODUCT10.2.0ORADATATROYCONTROL01.CTL – modified
Control File E:ORACLEPRODUCT10.2.0ORADATATROYCONTROL02.CTL – modified
Control File E:ORACLEPRODUCT10.2.0ORADATATROYCONTROL03.CTL – modified
Datafile E:ORACLEPRODUCT10.2.0ORADATATROYSYSTEM01.DBF – dbid
changed, wrote new name
Datafile E:ORACLEPRODUCT10.2.0ORADATATROYUNDOTBS01.DBF – dbid
changed, wrote new name
Datafile E:ORACLEPRODUCT10.2.0ORADATATROYSYSAUX01.DBF – dbid
changed, wrote new name
Datafile E:ORACLEPRODUCT10.2.0ORADATATROYUSERS01.DBF – dbid
changed, wrote new name
Control File E:ORACLEPRODUCT10.2.0ORADATATROYCONTROL01.CTL – dbid
changed, wrote new name
Control File E:ORACLEPRODUCT10.2.0ORADATATROYCONTROL02.CTL – dbid
changed, wrote new name
Control File E:ORACLEPRODUCT10.2.0ORADATATROYCONTROL03.CTL – dbid
changed, wrote new name
Instance shut down
Database name changed to HERCULES.
Modify parameter file and generate a new password file before restarting.
Database ID for database HERCULES changed to 1035501295.
All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID – Completed succesfully. - No need to Shutdown the database.( automatically disconnected ORA-03113: end-of-file on communication channel)
- Change the Sid name in listener & tnsnames.ora files. Reload the listener.
- Startup Mount using edited pfile.
Startup mount;
Alter database open resetlogs; - Select dbid, name from v$database;—>ensure the db name & dbid.
- Shutdown the database.
- Backup the database.
***************************************************************************
Method 3
Change the Oracle Database Name only
Database Name: troy
Our aim is to change the database name as Hercules.
Database Rename Steps
- Select dbid, name from v$database
- Shutdown the Database.
- Taken the complete cold backup. (Safer side)
- If database running on windows server, create the service id using oradim utility.
- If database running on UNIX based machine, change the oracle_sid name in .bash_profile (profile)
- Create new password file using new database name.
- Change the init parameter (dbname, instance name)
- Startup the database in MOUNT stage using new init parameter.
- Using below statement to change the database name only
$ NID TARGET=sys/pwd@troy DBNAME=HERCULES SETNAME=YES
Enter the Y in below prompt.
Change database ID and database name troy to Hercules? (Y/[N]) => Y - No need to Shutdown the database.( automatically disconnected ORA-03113: end-of-file on communication channel)
- Change the Sid name in listener & tnsnames.ora files. Reload the listener.
- Startup the database using edited pfile.
Note: No need to open the database using RESETLOGS option. - Select dbid, name from v$database – ensure the db name.
- Shutdown the database
- Backup the database.
*************************************************************************
Method 4
Change the Oracle DBID only
Database Name: troy
Our aim is to change the database name as Hercules.
DBID Rename Steps
- Select dbid, name from v$database
- Shutdown the Database.
- Take
n the complete cold backup. (Safer side) - Startup the database in MOUNT stage using new init parameter.
- Using below statement to change the dbid only
$ NID TARGET=sys/pwd@troy
Enter the Y in below prompt.
Change database ID and database name troy to Hercules? (Y/[N]) => Y - No need to Shutdown the database.( automatically disconnected ORA-03113: end-of-file on communication channel)
- Startup Mount using edited pfile
- Startup mount;
- Alter database open resetlogs;
- Select dbid, name from v$database –>ensure the dbid.
- Shutdown the database
- Backup the database.
I Hope this article helped you to understand the Rename of oracle database.Suggestions are welcome.