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
nice! thank you!
My pleasure!
Thank you, a good tip!
My pleasure!
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,
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';