Renaming the Oracle Database.
In this article we will learn how to rename a oracle database using trace controlfile .
RENAMING DATABASE :
Step 1 :
Check the database name
1 2 3 4 |
SYS>>select name from v$database; NAME ---------------------------------------- PRIMARY |
My Old Database name is PRIMARY
Step 2 :
Create a trace control file
1 2 3 |
SYS>>alter database backup controlfile to trace as '/u01/oradata/primary/trace.ctl'; Database altered. |
Step 3 :
Shutdown the database
1 2 3 4 5 6 7 |
SYS>>shut immediate; Database closed. Database dismounted. ORACLE instance shut down. SYS>>exit Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options |
Step 4 :
Go to CRD location and rename the controlfile
1 2 |
[oracle@dba12 ~]$ cd /u01/oradata/primary [oracle@dba12 hrts]$ mv control.ctl old.ctl |
Step 5 :
Open the trace file and remove unwanted lines
Need to change database name.
1 |
[oracle@dba12 hrts]$ vi trace.ctl |
Note :
If you want to Remove unnecessary lines & spaces,use “dd”.
If you want to Remove cursor above lines, “dgg”
If you want to Remove cursor Below lines, “d+G”
Replace “SET” instead of “REUSE”
Change the Database Name.
OLD Database Name is primary
New Database Name is prod
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
##########Inside trace file ################## STARTUP NOMOUNT CREATE CONTROLFILE set DATABASE "prod" RESETLOGS ARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 2 MAXDATAFILES 30 MAXINSTANCES 1 MAXLOGHISTORY 2921 LOGFILE GROUP 1 '/u01/oradata/primary/redo1.log' SIZE 4M BLOCKSIZE 512, GROUP 2 '/u01/oradata/primary/redo2.log' SIZE 4M BLOCKSIZE 512 -- STANDBY LOGFILE DATAFILE '/u01/oradata/primary/system.dbf', '/u01/oradata/primary/sysaux.dbf', '/u01/oradata/primary/undotbs.dbf', '/u01/oradata/primary/userdata.dbf', '/u01/oradata/primary/tts.dbf', '/disk1/oradata/hrts/tts23.dbf', '/disk1/oradata/hrts/tts232.dbf', '/disk1/oradata/hrts/bigts.dbf', '/u01/oradata/primary/db_2k.dbf', '/u01/oradata/primary/db_4k.dbf' CHARACTER SET US7ASCII; |
Step 6 :
Go to DBS location and open pfile
Change db_name parameter values
1 2 3 4 5 |
[oracle@dba12 hrts]$ cd $ORACLE_HOME/dbs [oracle@dba12 dbs]$ vi init$ORACLE_SID.ora NOTE: Change the Database Name as per Trace controlfile. DB_NAME:prod |
Step 7 :
Goto CRD file location
Connect to sqlplus and Run Trace file .
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[oracle@dba12 dbs]$ cd /u01/oradata/primary [oracle@dba12 primary]$ sqlplus / as sysdba SQL*Plus: Release 12.1.0.2.0 Production on Wed Jan 3 07:08:41 2001 Copyright (c) 1982, 2014, Oracle. All rights reserved. Connected to an idle instance. SYS>>@trace.ctl ORACLE instance started. Total System Global Area 260046848 bytes Fixed Size 2923192 bytes Variable Size 167773512 bytes Database Buffers 83886080 bytes Redo Buffers 5464064 bytes Control file created. |
Step 8 :
Check the database status , If it is mounted , Try to open database with resetlogs .
1 2 3 |
SYS>>alter database open resetlogs; Database altered. |
Step 9 :
Check Database Name:
1 2 3 4 5 |
SYS>>select name from v$database; NAME ---------------------------------------- PROD |
I hope above steps will be useful for renaming the database .
Thank you ……….