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

Rman encryption and other techniques

Today I will demonstrate Recovery Manager features, especially encryption and some other techniques. First of all let me note about RMAN backup encryption. Staring from Oracle 10g RMAN now creates encrypted backups that cannot be restored by unauthorized people. There are 3 modes of backup encryption: * Transparent encryption * Password encryption * Dual-mode encryption using either transparent or password encryption All RMAN backups are not encrypted but you can encrypt any RMAN backup in the form of a backup set. In this tutorial I will show you how to configure Password encryption. Let`s finish talking and start to demonstrate. check parameters with "SHOW ALL" command, by default encryption is OFF RMAN> show all; RMAN configuration parameters are: CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default CONFIGURE BACKUP OPTIMIZATION OFF; # default CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default CONFIGURE CONTROLFILE AUTOBACKUP ON; CONFIGURE CONTR...

ORA-03206: maximum file size of (5242880) blocks in AUTOEXTEND clause is out of range

Today when I want to change max size of datafile I got strange error. ALTER DATABASE DATAFILE '/u01/app/oracle/oradata/MYDB/users01.dbf' AUTOEXTEND ON NEXT 1280K MAXSIZE 32GB ORA-03206: maximum file size of (5242880) blocks in AUTOEXTEND clause is out of range Here is reason: The maximum file size for an autoextendable file has exceeded the maximum number of blocks allowed. After research internet I found that instead of using 32GB we can use 32767M. (same values but in MB). Or you may use 31GB too. ALTER DATABASE DATAFILE '/u01/app/oracle/oradata/MYDB/users01.dbf' AUTOEXTEND ON NEXT 1280K MAXSIZE 32767M;

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...