Skip to main content

Change production database name

Today I will show you how to rename existing database name. Before it take backup of your database and also please note that this step will change only database name not dbid.

My database name is prod2 and oracle version is 11g R2. I will change it to prod name.

SQL> select name from v$database;

NAME
---------
PROD2

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production

SQL>

[oracle@localhost ~]$ uname -n
localhost.localdomain

[oracle@localhost ~]$ more /etc/redhat-release 
Red Hat Enterprise Linux Server release 5.5 (Tikanga)

Firstly shutdown database and open it on mount mode.

[oracle@localhost ~]$ sql

SQL*Plus: Release 11.2.0.1.0 Production on Wed Mar 13 19:29:16 2013

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area  318046208 bytes
Fixed Size                  1336260 bytes
Variable Size             109055036 bytes
Database Buffers          201326592 bytes
Redo Buffers                6328320 bytes
Database mounted.
SQL> 

Now execute nid utility (dbnewid) and specify new database name.

[oracle@localhost ~]$ nid target =/ dbname=prod setname=YES

DBNEWID: Release 11.2.0.1.0 - Production on Wed Mar 13 19:33:07 2013

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to database PROD2 (DBID=1461820883)

Connected to server version 11.2.0

Control Files in database:
    /u01/app/oracle/oradata/prod2/control01.ctl
    /u01/app/oracle/flash_recovery_area/prod2/control02.ctl

Change database name of database PROD2 to PROD? (Y/[N]) => Y

Proceeding with operation
Changing database name from PROD2 to PROD
    Control File /u01/app/oracle/oradata/prod2/control01.ctl - modified
    Control File /u01/app/oracle/flash_recovery_area/prod2/control02.ctl - modified
    Datafile /u01/app/oracle/oradata/prod2/system01.db - wrote new name
    Datafile /u01/app/oracle/oradata/prod2/sysaux01.db - wrote new name
    Datafile /u01/app/oracle/oradata/prod2/undotbs01.db - wrote new name
    Datafile /u01/app/oracle/oradata/prod2/users01.db - wrote new name
    Datafile /u01/app/oracle/oradata/prod2/temp01.db - wrote new name
    Control File /u01/app/oracle/oradata/prod2/control01.ctl - wrote new name
    Control File /u01/app/oracle/flash_recovery_area/prod2/control02.ctl - wrote new name
    Instance shut down

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

[oracle@localhost ~]$ 


Create new name directories in admin folder

[oracle@localhost admin]$ mkdir prod
[oracle@localhost admin]$ cd prod
[oracle@localhost prod]$ mkdir adump dpdump pfile


Last action is change pfile and password file and open database with resetlogs option.

[oracle@localhost pfile]$ pwd
/u01/app/oracle/admin/prod2/pfile

[oracle@localhost pfile]$ ls
init.ora.2132013192312

[oracle@localhost pfile]$ cat init.ora.2132013192312 | grep db_name
db_name=prod2

#change db_name to new db_name
#change audit_file_dest to new path : /u01/app/oracle/admin/prod/adump
[oracle@localhost pfile]$ vi init.ora.2132013192312

[oracle@localhost pfile]$ cat init.ora.2132013192312 | grep db_name
db_name=prod


[oracle@localhost pfile]$ cat init.ora.2132013192312 | grep audit_file
audit_file_dest=/u01/app/oracle/admin/prod/adump

[oracle@localhost dbs]$ pwd
/u01/oracle/product/11.2.0/db_1/dbs

[oracle@localhost dbs]$ orapwd file=orapwprod entries=5 ignorecase=y password=oracle

[oracle@localhost dbs]$ export | grep ORACLE_SID
declare -x ORACLE_SID="prod"
[oracle@localhost dbs]$ 


mv init file from ../prod2/pfile/ to ../prod/pfile/
and recreate spfile

[oracle@localhost dbs]$ export | grep ORACLE_SID
declare -x ORACLE_SID="prod"
[oracle@localhost dbs]$ sql

SQL*Plus: Release 11.2.0.1.0 Production on Wed Mar 13 19:52:23 2013

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

Connected to an idle instance.

SQL> shut immediate
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux Error: 2: No such file or directory
SQL> shut abort;
ORACLE instance shut down.

SQL> create spfile from pfile='/u01/app/oracle/admin/prod/pfile/init.ora.2132013192312';

File created.

SQL> 

SQL> startup mount
ORACLE instance started.

Total System Global Area  318046208 bytes
Fixed Size                  1336260 bytes
Variable Size             109055036 bytes
Database Buffers          201326592 bytes
Redo Buffers                6328320 bytes
Database mounted.

SQL> alter database open;

Database altered.

SQL> select name from v$database;

NAME
---------
PROD

SQL> 


Comments

Popular posts from this blog

Fix ORA-01139: RESETLOGS option only valid after an incomplete database recovery

While shutting down my TEST database process was hanged. Then I had to use shutdown abort. But when I wanted to start database it did not open. SQL> select name from v$database; NAME --------- TEST SQL> shut abort; ORACLE instance shut down. SQL> startup mount ORACLE instance started. Total System Global Area 6597406720 bytes Fixed Size 2265664 bytes Variable Size 3204451776 bytes Database Buffers 3372220416 bytes Redo Buffers 18468864 bytes Database mounted. SQL> alter database open; alter database open * ERROR at line 1: ORA-03113: end-of-file on communication channel Process ID: 6552 Session ID: 191 Serial number: 3  What`s wrong?  SQL> alter database open resetlogs; ERROR:    ORA-03114: not connected to ORACLE    SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Pr...

Fix: ORA-13639: The current operation was interrupted because it timed out.

Sometimes SQL Tuning Advisor interrupts cause time limit took more than defined. You have to analyze it or increase value. Here you can see increasing of value. Example result of sql select                  execution_name, advisor_name,                  to_char(execution_start,'dd-mon-yy hh:mi:ss') execution_start,                  to_char(execution_end,'dd-mon-yy hh:mi:ss') execution_end, status,error_message from dba_advisor_executions where task_name = 'SYS_AUTO_SQL_TUNING_TASK' order by execution_start; Check value of TIME_LIMIT`s parameter : SQL> column parameter_value for A35 SQL> select parameter_name, parameter_value from dba_advisor_parameters where task_name = 'SYS_AUTO_SQL_TUNING_TASK' and parameter_name in ('TIME_LIMIT', 'DEFAULT_EXECUTION_TYP...

How to fix ORA-26040: Data block was loaded using the NOLOGGING option

Today I faced with new ORA error. After solving I want to share this experience with yours. So, today 5`th datafile of my database was corrupted (/u01/app/oracle/oradata/ulfet_db/example01.dbf). After recover via RMAN I saw strange error. RMAN> recover datafile 5 block 443; Starting recover at 24-MAR-13 using channel ORA_DISK_1 channel ORA_DISK_1: restoring block(s) channel ORA_DISK_1: specifying block(s) to restore from backup set restoring blocks of datafile 00005 channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/ULFET_DB/backupset/2013_03_24/o1_mf_nnndf_TAG20130324T223233_8nykp220_.bkp channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/ULFET_DB/backupset/2013_03_24/o1_mf_nnndf_TAG20130324T223233_8nykp220_.bkp tag=TAG20130324T223233 channel ORA_DISK_1: restored block(s) from backup piece 1 channel ORA_DISK_1: block restore complete, elapsed time: 00:00:03 starting media recovery media recovery complete, elapsed ti...