This procedure does not require resetlogs so previously taken backups will be valid after this operation. However database restart is needed at some points so maintenance with downtime should be scheduled for this operation.
You may follow “Changing Only the Database Name” topic at official document:
http://download.oracle.com/docs/cd/B14117_01/server.101/b10825/dbnewid.htm#i1004734
$cd $ORACLE_HOME/dbs
#backup old initora file
$mv initMYOLDSID.ora initMYOLDSID.ora.org
#create pfile from spfile
$sqlplus '/ AS SYSDBA'
SQL> create pfile from spfile;
SQL> exit
#replace all old dbname parameters with new dbname in pfile. Becareful, if you change some path variables, make sure that new path (including new dbname) also exists on system. If not, create manually.
$vi initMYOLDSID.ora
vi=> :%s/MYOLDDBNAME/MYNEWDBNAME/g
vi=> :wq
#now database goes offline...
$sqlplus '/ AS SYSDBA'
SQL> SHUTDOWN IMMEDIATE
SQL> STARTUP MOUNT
SQL> exit
#change dbname using nid. Output is similar to fallowing...
$nid TARGET=/ DBNAME=MYNEWDBNAME SETNAME=YES
DBNEWID: Release 11.2.0.1.0 - Production on ....
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to database MYOLDDBNAME (DBID=XXXXXXXXX)
Connected to server version 11.2.0
Control Files in database:
/db_ctrl_path/ctrl1.ctl
/db_ctrl_path/ctrl2.ctl
Change database name of database MYOLDDBNAME to MYNEWDBNAME? (Y/[N]) => Y
Proceeding with operation
Changing database name from MYOLDDBNAME to MYNEWDBNAME
Control File /db_ctrl_path/ctrl1.ctl - modified
Control File /db_ctrl_path/ctrl2.ctl - modified
Datafile /db_data_path/file1.db - wrote new name
Datafile /db_data_path/file2.db - wrote new name
Datafile /db_data_path/file3.db - wrote new name
...
Control File /db_ctrl_path/ctrl1.ctl - wrote new name
Control File /db_ctrl_path/ctrl2.ctl - wrote new name
Instance shut down
Database name changed to MYNEWDBNAME.
Modify parameter file and generate a new password file before restarting.
Succesfully changed database name.
DBNEWID - Completed succesfully.
#Change ORACLE_SID environment variable
$vi $HOME/.profile
vi=> change ORACLE_SID from MYOLDSID to MYNEWSID
$. $HOME/.profile
$env|grep SID
ORACLE_SID=MYNEWSID
#Create new password file and rename pfile..
$orapwd file=$ORACLE_HOME/dbs/orapwMYNEWSID password=xxxx entries=5
$mv initMYOLDSID.ora initMYNEWSID.ora
#Start database with new pfile and create spfile.
$sqlplus '/ AS SYSDBA'
SQL> startup pfile=oracle_home_path/dbs/initMYNEWSID.ora
ORACLE instance started.
…
SQL> select name from v$database;
NAME
---------
MYNEWDBNAME
SQL> create spfile from pfile;
#Note that database is opened using pfile so no spfile operation will be allowed. You should restart database again without pfile parameter to open it with spfile.
1 comment:
This came to my rescue, thanks so much! There were two points where I had to diverge from your plan, maybe it will help someone else:
1. I had to shutdown and mount the DB before I changed the pfile, otherwise it complained about the unknown db_name.
2. I'm on a Windows server, and had to use the OraDim utility to remove the OracleServiceOld service and replace it with a OracleServiceNew service.
Thanks again!
Post a Comment