Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2003
    Posts
    20

    Unanswered: How to display the current user of SQL*Plus??

    Sometimes I just cant remember or dont know the user/account for current SQL*Plus session. Any SQL*Plus command can display it? Many thnx...

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    SQL> show user
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Jun 2003
    Posts
    20
    wow, it works... thnx a lot mate...

  4. #4
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    If you create a file called login.sql and place it in the bin directory of your oracle client's home directory, your prompt in sqlplus will always show you what user and database that you are using. The content of the login.sql file follow.


    Code:
    set termout off
    col prom new_value prom
    select lower(sys_context('USERENV','SESSION_USER'))||
           '@'||
           lower(sys_context('USERENV','DB_NAME'))||'>' prom
      from dual;
    set sqlprompt "&prom"
    undefine prom
    column prom clear
    set termout on
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  5. #5
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,799
    Provided Answers: 11
    Nice tip. Thanks, Beilstwh.

  6. #6
    Join Date
    Jun 2003
    Posts
    20
    wow, that's a better one. Many thnx...

  7. #7
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >sqlplus will always show you what user and database that you are using.

    Not ALWAYS, ALWAYS!

    IIRC, there two cases where it does not work as advertized.
    1) If the DB is down & you use SQL*Plus to start the DB. The query fails.
    2) Prior to V10 & did, SQL> connect scott/tiger@newdb; prompt remained unchanged.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  8. #8
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    Thanks ana,
    I meant to mention the pre version 10 problem but forgot.

    If you startup sqlplus and login in, it will be correct. If you use the connect command in any client version before 10, it will not reflect the change. There are three ways to overcome this problem.

    1) Don't use connect, exit sqlplus and restart.
    2) manually run the login.sql script
    3) upgrade to the version 10 client. I use it on 8i, 9i, and 10g databases with no problem.
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •