Monday, July 18, 2005

Which instance am I in?

Here's an easy one a colleague asked me.

You are logged into your default session (example: sqlplus scott/tiger with no @instance)

You want to know which instance you are logged into.

You can't query V$ tables directly, because you're not logged in as SYS.

So while looking around at similar questions on Jonathan Lewis' cooperative FAQ:

I saw SYS_CONTEXT. That looked like it would do the trick. So I looked it up in my favourite reference, Dan Morgan's:

And came up with this:


You can also get the 'INSTANCE' using this, but that doesn't do you any good if you can't query the V$INSTANCE table.

That solves the problem, but I'm sure that's just one of many ways to do it:

1. Some other queries on some system tables, and/or
2. Some command-line command, and/or
3. Some environment file somewhere.

Also, I know some people who put this directly into their sqlplus prompt.

Eddie Awad wrote a post on SYS_CONTEXT as well:
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?