After restoring production database to test for UAT or dev purposes, we may need to change the database name as well as DBID. When DBID is maintained unique, RMAN backup can be triggered for the restored database if we use recovery catalog. Let us see how to change both database name
and the DBID. You can opt to change just the database name.
First let us see the name and the DBID as below:
SQL> select name,dbid from v$database;
NAME DBID
--------- ----------
PRDIMP 47133164
To change the database name and the DBID, ensure that the database is in mounted state:
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
MOUNTED
and the DBID. You can opt to change just the database name.
First let us see the name and the DBID as below:
SQL> select name,dbid from v$database;
NAME DBID
--------- ----------
PRDIMP 47133164
To change the database name and the DBID, ensure that the database is in mounted state:
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
MOUNTED
The tool 'nid' helps us change both name and DBID. Let us see the parameters of nid as below:
[oracle@myserver ~]$ nid
DBNEWID: Release 11.2.0.4.0 - Production on Wed Aug 26 12:59:19 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Keyword Description (Default)
----------------------------------------------------
TARGET Username/Password (NONE)
DBNAME New database name (NONE)
LOGFILE Output Log (NONE)
REVERT Revert failed change NO
SETNAME Set a new database name only NO
APPEND Append to output log NO
HELP Displays these messages NO
As shown above, DBNAME accepts the new database name. If you make the SETNAME parameter to YES, only the database name will get changed.
Execute the below to change the name only:
[oracle@myserver ~]$ nid TARGET=sys/ DBNAME=TSTIMP SETNAME='YES' LOGFILE=nid.log
Execute the below to change the name and DBID:
[oracle@myserver ~]$ nid TARGET=sys/ DBNAME=TSTIMP SETNAME='NO' LOGFILE=nid.log
This takes a few seconds to change the name. The log file can be located at the current working directory.
After executing the above command, ensure that you copy your parameter file to reflect the new name as below:
[oracle@myserver dbs]$ cp initPRDIMP.ora initTSTIMP.ora
And change db_name in your parameter file. If it is a clustered setup, add instance_name as well. Once the change is made, startup the database using resetlogs if you opted to change both. If you just changed the name, you don't have to open using reset logs.
SQL> alter database open resetlogs;
Database altered.
SQL> select name,dbid from v$database;
NAME DBID
--------- ----------
TSTIMP 2323285955
Both got changed as executed the second command.
Now you can make entries in your /etc/oratab file to reflect your changed database name.
This is how we change the database name and the DBID using nid utility.
A word of caution: If you change the DBID of a database, all the backups and archive logs become unusable!
A word of caution: If you change the DBID of a database, all the backups and archive logs become unusable!
No comments:
Post a Comment