Search

Join this Blog for direct reference of any post into your inbox. To join just click on "Join this Site" under "Follower" then Login with your Email.*** DECLARATION: I Maintain this Blog for Helping Myself While at Work and Welcome any body Needing Help!!!.*** CAUTION: Using any of the script from this Blog may contain at Own Risk. These scripts May or May not have been Tested.***

Monday, 12 March 2012

CHANGING DBID and DBNAME

DBID and DBNAME
1. Backup the database before changing DBID for security
2. Mount the database after a clean shutdown.‎
SQL>SHUTDOWN IMMEDIATE;
SQL>STARTUP MOUNT;
3. Invoke the DBNEWID utility (nid) specifying the new DBNAME from the command line using ‎a user  with SYSDBA privilege.‎
CMD>nid TARGET=sys/password@TSH1 DBNAME=TSH2‎
Assuming the validation is successful the utility prompts for confirmation before performing the ‎actions.‎
Shutdown the database.‎
4. SQL>SHUTDOWN IMMEDIATE;
Modify the DB_NAME parameter in the initialization parameter file. The startup will result in an ‎error but proceed anyway.‎
SQL>STARTUP MOUNT;
SQL>ALTER SYSTEM SET DB_NAME=TSH2 SCOPE=SPFILE;‎
SQL>SHUTDOWN IMMEDIATE;
5. Create a new password file.‎
orapwd file=c:\oracle\920\database\pwdTSH2.ora password=password entries=10‎
6. Rename the SPFILE to match the new DBNAME.‎
If you are using Windows you must recreate the service so the correct name and parameter file ‎are used.‎
CMD>oradim -delete -sid TSH1‎
CMD>oradim -new -sid TSH2 -intpwd password -startmode a -pfile ‎c:\oracle\920\database\spfileTSH2.ora
If you are using UNIX/Linux simply reset the ORACLE_SID environment variable.‎
$>ORACLE_SID=TSH2; export ORACLE_SID
7. Alter the listener.ora and tnsnames.ora setting to match the new database name and restart the ‎listener.‎
CMD>lsnrctl reload
Open the database with RESETLOGS.‎
SQL>STARTUP MOUNT
SQL>ALTER DATABASE OPEN RESETLOGS;‎
8. You must Backup the database after changing DBID
DBNAME Only
1. Repeat the process as before except use the following command to start the DBNEWID utility.‎
SQL>SHUTDOWN IMMEDIATE
SQL>STARTUP MOUNT
nid TARGET=sys/password@TSH2 DBNAME=TSH3 SETNAME=YES
Note:The SETNAME parameter tells the DBNEWID utility to only alter the database name.‎
When opening the database the RESETLOGS option is not needed so the database can be started ‎using the STARTUP command.‎
2. SQL>SHUTDOWN IMMEDIATE
Modify the DB_NAME parameter in the initialization parameter file. The startup will result in an ‎error but proceed anyway.‎
SQL>STARTUP MOUNT
SQL>ALTER SYSTEM SET DB_NAME=TSH2 SCOPE=SPFILE;‎
SQL>SHUTDOWN IMMEDIATE
or Set in the DB_NAME initialization parameter in the initialization parameter file (PFILE) to the ‎new database name.‎
Note: The DBNEWID utility does not change the server parameter file (SPFILE). Therefore, if you use ‎SPFILE to start your Oracle database, you must re-create the initialization parameter file from ‎the server parameter file, remove the server parameter file, change the DB_NAME in the ‎initialization parameter file, and then re-create the server parameter file.‎
Because you have changed only the database name, and not the database ID, it is not necessary ‎to use the RESETLOGS option when you open the database. This means that all previous ‎backups are still usable.‎
3. Create a new password file.‎
orapwd file=c:\oracle\920\database\pwdTSH2.ora password=password entries=10‎
4. Open the database without Reset logs option
SQL>Startup;‎
DBID Only
1. Backup the database before doing this
2. Mount the database after a clean shutdown.‎
SQL>SHUTDOWN IMMEDIATE
SQL>STARTUP MOUNT
nid TARGET=sys/password@TSH3‎
4. Shutdown and open the database with RESETLOGS.‎
SQL>SHUTDOWN IMMEDIATE
SQL>STARTUP MOUNT
SQL>ALTER DATABASE OPEN RESETLOGS;‎
5. you must Backup the database. after changing DBID
Changing Global Database Names
SQL>ALTER DATABASE RENAME GLOBAL_NAME TO <newname>.<domain>;‎
Example:‎
SQL>ALTER DATABASE RENAME GLOBAL_NAME TO Orcl3.world
Restrictions on DBNEWID
To change the DBID of a database, the database must be mounted and must have been shut down ‎consistently prior to mounting. In the case of an Oracle Real Application Clusters database, the ‎database must be mounted in NOPARALLEL mode.‎
You must open the database with the RESETLOGS option after changing the DBID. However, ‎you do not have to open with the RESETLOGS option after changing only the database name.‎
No other process should be running against the database when DBNEWID is executing. If ‎another session shuts down and starts the database, then DBNEWID terminates unsuccessfully.‎
All online datafiles should be consistent without needing recovery.‎
Normal offline datafiles should be accessible and writable. If this is not the case, you must drop ‎these files before invoking the DBNEWID utility.‎
All read-only tablespaces must be accessible and made writable at the operating system level ‎prior to invoking DBNEWID. If these tablespaces cannot be made writable (for example, they ‎are on a CD-ROM), then you must unplug the tablespaces using the transportable tablespace ‎feature and then plug them back in the database before invoking the DBNEWID utility.‎
The DBNEWID utility does not change global database names

0 comments:

Post a Comment