Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How I get Schema-Name from sql query

Re: How I get Schema-Name from sql query

From: Paul Bennett <bennett_at_cc.gatech.edu>
Date: Wed, 05 Jan 2000 00:38:35 GMT
Message-ID: <387292C8.A73F7166@cc.gatech.edu>


This is incorrect.

select USER from dual will tell you the current user, not the current schema. It is possible for the current schema to be different from the current user.

SQLWKS> connect bennettp_at_lto8
Connected.
SQLWKS> select USER from dual

     2>
USER



BENNETTP
1 row selected.
SQLWKS> select count(*) from mda.assignment

     2>
COUNT(*)


     10172
1 row selected.
SQLWKS> select count(*) from assignment

     2>
select count(*) from assignment

                     *

ORA-00942: table or view does not exist SQLWKS> alter session set current_schema = MDA

     2>
Statement processed.
SQLWKS> select count(*) from assignment

     2>
COUNT(*)


     10172
1 row selected.
SQLWKS> select user from dual

     2>
USER



BENNETTP
1 row selected.

The schema = MDA, but the USER = bennettp

RC wrote:

> pook4431 wrote:
> >
> >
> > How I get schema name for schema that I'm using by sql query?
> >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
> Try select USER from dual; That will give you the schema that is currently
> running.
>
> HTH
>
> RC
>
> --
> Posted via CNET Help.com
> http://www.help.com/
Received on Tue Jan 04 2000 - 18:38:35 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US