Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change SID From Inside SQLPlus 2

Status
Not open for further replies.

Michael42

Programmer
Joined
Oct 8, 2001
Messages
1,454
Location
US
Hello,

Can anyone show me how to change an ORACLE_SID from inside SQLPlus?

Thanks,

Michael42
 
Michael,

Before we assist you in shooting yourself in the foot, could you place your question in a bit more context? What is your objective in wanting to change ORACLE_SID from within SQL*Plus? What do you hope to accomplish?

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I can provide you with low-cost, remote Database Administration services: see our website and contact me via www.dasages.com]
 
Santa,

I have Bourne shell script I have been asked to write that cycles though a list of Database SID's and will attempt to close them. My problem is that it needs to be run as root and though my attempts to emulate the proper environment seem to be mostly effective (I also have it shutting down various services) if I could change the SID from inside a SQLPlus session that would give me another option.

If it is possible I would like to test it.

Thanks for the post sir,

Michael42
 
Ah, yes, I understand now. (I completely misunderstood what you wanted to do, I believe.)

I you wish to cycle through a list of Oracle instances and shut them down from within the SQL*Plus environment, then you can do so provided the following:

On each target database that you want to remotely shutdown:

1) Ensure that you have the following instance parameter set:
Remote_login_passwordfile=EXCLUSIVE

2) You have used the "orapwd" utility to create an Oracle "password file".

On the client SQL*Plus from which you wish to remotely shutdown another database (i.e., in your words, "change ORACLE_SID"):
Code:
sqlplus /nolog
connect sys/<pw>@<TNS alias for Instance 1> as sysdba
shutdown immediate

connect sys/<pw>@<TNS alias for Instance 2> as sysdba
shutdown immediate

et cetera
If you have residual questions about any of the above, please advise us.


[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I can provide you with low-cost, remote Database Administration services: see our website and contact me via www.dasages.com]
 
Hi,
Pass a list of the tns aliases to the shell and use something like this;
( Have not written shell scripts in a vary long time so, just pseudo-code):

SqlPlus /nolog
Loop for each alias in the passed list
connect user/pass@<passedalias> as sysdba
Do something
finish with this alias
next alias
finish
exit






[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Santa,

Nicely done sir. :-)

Thanks,

Michael42
 
Turkbear,

Yes - I get it...finally. It took me a few passses to "see" it. That is a cool technique.

Thanks for posting,

Michael42



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top