Skip to content
Home » Oracle » Oracle Who am I

Oracle Who am I

Sometimes, you switched the connection to another schema for more operations and forgot where you are. Here are some ways to know who am I (whoami in Linux).

SQL*Plus

If you're in sqlplus, you check it with the short cut.

SQL> show user
USER is "SCOTT"

USER() Function

If you're not in sqlplus, you can also check the information by querying the environmental function USER().

SQL> select user from dual;

USER
------------------------------
SCOTT

Dictionary View

Typically and officially, you can query your own dictionary USER_USERS for sure.

SQL> select distinct username from user_users;

USERNAME
---------------
SCOTT

SYS_CONTEXT

From the system point of view, we can check current session user by SYS_CONTEXT() function.

SQL> select sys_context('USERENV', 'SESSION_USER') "USER" from dual;

USER
--------------------
SCOTT

6 thoughts on “Oracle Who am I”

  1. Hi
    Is it possible to retrieve “My_Object_Name” (Function / procedure / Package) from within the object?
    Is it possible to retrieve “Line_Number” from within the object?
    Thanks in advance,
    Ronen Israel,

    1. You can retrieve the information from USER_SOURCE view. For example:

      select line, text from user_source where type = 'PROCEDURE' and name = 'ADD_JOB_HISTORY';

Leave a Reply

Your email address will not be published. Required fields are marked *