banner



How To Change Sid In Oracle

How to rename an Oracle database ORACLE_SID?

Oracle Database Tips by Donald BurlesonApril 21, 2015

Question: I want to re-name my database to change the ORACLE_SID value.  I have changed the instance_name parameter in parameter file also but its still at database said showing same when we select instance_name from v$instance?  What is the proper way to re-name an Oracle instance?

Answer: To completely re-name a database you need to change all of the components where the instance name is located:

  • External files: sqlnet.ora, tnsnames.ora, init.ora (spfile)

  • Internal locations:  Data dictionary

Here are the "traditional" steps to re-name an Oracle database (note new procedure for renaming an instance in 9i and beyond later on this page):

STEP 1: On the old system, go into SQL*Plus, sign on as SYSDBA and issue: ?alter database backup controlfile to trace?. This will put the create database syntax in the trace file directory. The trace keyword tells oracle to generate a script containing a create controlfile command and store it in the trace directory identified in the user_dump_dest parameter of the init.ora file. It will look something like this:

STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "OLDLSQ" NORESETLOGS
NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 240
MAXINSTANCES 1
MAXLOGHISTORY 113
LOGFILE
GROUP 1 ('/u03/oradata/oldlsq/log1a.dbf',
'/u03/oradata/olslsq/log1b.dbf') SIZE 30M,
GROUP 2 ('/u04/oradata/oldlsq/log2a.dbf',
'/u04/oradata/oldlsq/log2b.dbf') SIZE 30M
DATAFILE
'/u01/oradata/oldlsq/system01.dbf',
'/u01/oradata/oldlsq/mydatabase.dbf'
;
# Recovery is required if any of the datafiles are restored
# backups, or if the last shutdown was not normal or immediate.
RECOVER DATABASE
# Database can now be opened normally.
ALTER DATABASE OPEN;

STEP 2: Shutdown the old database

STEP 3: Change all references to the old instance name in all locations for sqlnet.ora, protocol.ora, tnsnames.ora and the init.ora (or spfile for the database).

STEP 4: Change the database name in the file to reference the new ORACLE_SID instance name:

STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "NEWLSQ" NORESETLOGS
NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 240
MAXINSTANCES 1
MAXLOGHISTORY 113
LOGFILE
GROUP 1 ('/u03/oradata/newlsq/log1a.dbf',
'/u03/oradata/newlsq/log1b.dbf') SIZE 30M,
GROUP 2 ('/u04/oradata/newlsq/log2a.dbf',
'/u04/oradata/newlsq/log2b.dbf') SIZE 30M
DATAFILE
'/u01/oradata/newlsq/system01.dbf',
'/u01/oradata/newlsq/mydatabase.dbf'
;
# Re-named database can now be opened normally.
ALTER DATABASE OPEN RESETLOGS;
ALTER TABLESPACE TEMP ADD TEMPFILE ''/u04/oradata/newlsq/log2a.dbf/temp.dbf'
SIZE 104857600 REUSE AUTOEXTEND OFF;

A new method for a database rename instance

For Oracle9i and beyond, Oracle author Dr. Tim Hall has this procedure to rename an Oracle database using the new dbnewid (also called nid, for new ID) utility:

  • STEP 1: Backup the database.
  • STEP 2: Mount the database after a clean shutdown:
    SHUTDOWN IMMEDIATE STARTUP MOUNT
  • STEP 3: Invoke the DBNEWID utility (nid) specifying the new DBNAME from the command line using a user with SYSDBA privilege:
    nid TARGET=sys/password@TSH1 DBNAME=TSH2
    Assuming the validation is successful the utility prompts for confirmation before performing the actions. Typical output may look something like:
                                  C:\oracle\920\bin>nid TARGET=sys/password@TSH1 DBNAME=TSH2 DBNEWID: Release 9.2.0.3.0 - Production Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.  Connected to database TSH1 (DBID=1024166118)  Control Files in database:     C:\ORACLE\ORADATA\TSH1\CONTROL01.CTL     C:\ORACLE\ORADATA\TSH1\CONTROL02.CTL     C:\ORACLE\ORADATA\TSH1\CONTROL03.CTL  Change database ID and database name TSH1 to TSH2? (Y/[N]) => Y  Proceeding with operation Changing database ID from 1024166118 to 1317278975 Changing database name from TSH1 to TSH2     Control File C:\ORACLE\ORADATA\TSH1\CONTROL01.CTL - modified     Control File C:\ORACLE\ORADATA\TSH1\CONTROL02.CTL - modified     Control File C:\ORACLE\ORADATA\TSH1\CONTROL03.CTL - modified     Datafile C:\ORACLE\ORADATA\TSH1\SYSTEM01.DBF - dbid changed, wrote new name     Datafile C:\ORACLE\ORADATA\TSH1\UNDOTBS01.DBF - dbid changed, wrote new name     Datafile C:\ORACLE\ORADATA\TSH1\CWMLITE01.DBF - dbid changed, wrote new name     Control File C:\ORACLE\ORADATA\TSH1\CONTROL01.CTL - dbid changed, wrote new name     Control File C:\ORACLE\ORADATA\TSH1\CONTROL02.CTL - dbid changed, wrote new name     Control File C:\ORACLE\ORADATA\TSH1\CONTROL03.CTL - dbid changed, wrote new name                              Database name changed to TSH2. Modify parameter file and generate a new password file before restarting. Database ID for database TSH2 changed to 1317278975. All previous backups and archived redo logs for this database are unusable. Shut down database and open with RESETLOGS option. Succesfully changed database name and ID. DBNEWID - Completed succesfully.                            
  • STEP 4: Shutdown the database:
                                  SHUTDOWN IMMEDIATE                            
  • STEP 5: Modify the DB_NAME parameter in the initialization parameter file. The startup will result in an error but proceed anyway.
                                  STARTUP MOUNT ALTER SYSTEM SET DB_NAME=TSH2 SCOPE=SPFILE; SHUTDOWN IMMEDIATE                            
  • STEP 6: Create a new password file:
                                  orapwd file=c:\oracle\920\database\pwdTSH2.ora password=password entries=10                            
  • STEP 7: Rename the SPFILE to match the new DBNAME.
  • STEP 8: If you are using Windows you must recreate the service so the correct name and parameter file are used:
                                  oradim -delete -sid TSH1 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
  • STEP 9: Alter the listener.ora and tnsnames.ora setting to match the new database name and restart the listener:
    lsnrctl reload
  • STEP 10: Open the database with RESETLOGS:
                                  STARTUP MOUNT ALTER DATABASE OPEN RESETLOGS;                            
  • STEP 11: Backup the database.

For related notes, see:

  • Cloning a Database

  • easy clone/copy of oracle database

  • Cloning a large RAC database

If you like Oracle tuning, you might enjoy my book "Oracle Tuning: The Definitive Reference", with 950 pages of tuning tips and scripts.

You can buy it direct from the publisher for 30%-off and get instant access to the code depot of Oracle tuning scripts.


How To Change Sid In Oracle

Source: http://www.dba-oracle.com/t_rename_database_oracle_sid.htm

Posted by: dominickweled1942.blogspot.com

0 Response to "How To Change Sid In Oracle"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel