How can I change the SID of an Oracle XE instance
Asked Answered
H

3

13

I needed to change the SID of an Oracle XE database (not the Service Name) to match a production database.

When I tried searching online, most of the pages were describing changing or adding a service name through tnsnames.ora; that's not what I needed to do.

Heilner answered 4/1, 2009 at 13:4 Comment(0)
R
14

The asktom article has the answer, but the formatting and verbosity makes it hard to follow, so here's a summary:

[XE_HOME] means where Oracle XE is installed. Normally this is C:\oraclexe\app\oracle\product\10.2.0\server.

Make sure you have Administrator privileges or the procedure will fail.

  1. Configure the SPFILE (you can remove the old file if you want)
    1. copy [XE_HOME]\dbs\spfileXE.ora [XE_HOME]\dbs\spfileNEW_SID_NAME.ora
    2. copy [XE_HOME]\database\initXE.ora [XE_HOME]\database\initNEW_SID_NAME.ora
    3. Edit [XE_HOME]\database\initNEW_SID_NAME.ora: It should contain a single line like this: SPFILE='[XE_HOME]\server\dbs/spfileNEW_SID_NAME.ora'
  2. Shutdown and replace the old service with a new:
    1. sqlplus / as sysdba and execute shutdown
    2. lsnrctl stop
    3. oradim -new -sid NEW_SID_NAME -startmode auto -pfile [XE_HOME]\database\initNEW_SID_NAME.ora
    4. oradim -delete -sid XE
    5. lsnrctl start
  3. Update the ORACLE_SID environment property (System Settings > Advanced > Environment)
  4. Force Oracle to register with listener
    • sqlplus / as sysdba and execute alter system register;

You can verify that the SID was changed by executing the following query: select instance_name from v$instance;

Rutabaga answered 6/8, 2010 at 14:8 Comment(1)
Thanks, I didn't like the idea of accepting my own answer. Your answer is much clearer,Heilner
T
3

I had some problems with the solution posted by Johannes, so I had to do some extra steps. When trying to connect to oracle (step 4) by doing sqlplus / as sysdba I got:

ERROR: ORA-12560: TNS:protocol adapter error

The solution for this was executing the following line:

oradim -start -sid NEW_SID_NAME

Then connecting with / worked fine, but trying to connect to NEW_SID_NAME with system or HR got me another problem:

ERROR: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

I checked that with the query select instance_name from v$instance; that the listener would be NEW_SID_NAME, and so did. But running lsnrctl status in the command line or querying select name from dba_services; didn't show NEW_SID_NAME as a listener. The solution of this problem was executing the followind sentence on sqlplus:

alter system set service_names='NEW_SID_NAME';

Maybe you'll need to execute alter system register; after this also.

After doing this two steps I can connect to the NEW_SID_NAME with system and HR.

Hope it helps

Thermoplastic answered 5/12, 2012 at 13:57 Comment(1)
Sorry, I forgot, the links that I used to solve this problems where mdvreddy.blogspot.com.ar/2011/12/… and forums.oracle.com/forums/thread.jspa?messageID=10201664Thermoplastic
S
1

In version 11g, all of the previous solution didn't work... I always get the following error when trying to do the sqlplus / as sysdba :

ERROR: ORA-12560: TNS:protocol adapter error

Luckily I found a script to do what I wanted to do under [XE_HOME]\config\scripts. The script is named XE.bat and it will instantiate a new database from scratch asking you for the sysPassword along the process. So what I did was :

  1. Stop and remove the existing service if any:

oradim -delete -sid XE

  1. Stop the listener
  2. Configure the SPFILE as explained by Johannes
  3. Make a copy of the script XE.bat, you can name it whatever you want
  4. Edit the copy of the script as follows :

    1. Change line "set ORACLE_SID=XE" to "set ORACLE_SID=NEW_SID_NAME"
    2. Change wherever you see "-sid XE" to "-sid NEW_SID_NAME"
    3. Update the line where it calls the "orapwd.exe" command to point to a file called PWDNEW_SID_NAME.ora instead of PWDXE.ora
    4. Update the line that echos the spfileXE.ora into the initXE.ora to echo spfileNEW_SID_NAME.ora into initNEW_SID_NAME.ora (this part may render the step 3 useless but I prefer to do it anyway, just in case...)
  5. Execute the script... It will prompt you for the SYSTEM password a few times saying

Enter value for 1:

or

Enter value for 2:

That's it, the new database with your NEW_SID_NAME is up and running!!

Shastashastra answered 16/3, 2018 at 21:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.