➤ EMP DEPT Tables Queries
➤ Set Operators in Oracle
➤ CREATE command
➤ RENAME command
➤ DROP command
➤ Default Value in Column
➤ ABS() in Oracle SQL
➤ CEIL() in Oracle SQL
➤ SYSDATE in Oracle
➤ Trunc Oracle date
➤ TO_CHAR() in Oracle
➤ GROUP BY Clause
➤ Having Clause
➤ ORDER BY Clause
➤ Constraints in Oracle
➤ Rename Constraint
➤ Disable Constraint
➤ Drop Constraint
➤ NOT NULL Constraint
➤ UNIQUE Constraint
➤ PRIMARY KEY Constraint
➤ FOREIGN KEY Constraint
➤ CHECK Constraint
➤ Unlock User in SQL Plus
➤ Find SID in Oracle database
➤ Check Database Version
➤ Check Database Size
➤ Error ORA 01031
Oracle Show Current User | In the previous tutorial, we see how to list all users of the Oracle database? How we can use ALL_USERS and DBA_USERS views to list all users. Now, in this tutorial, we will see how to show the current users in the Oracle database?
Show current user name in Oracle using dual,
SELECT user FROM dual;
Output:-
USER
------------------------------
KNOWP
Using sys_context to show the current user in the Oracle database,
SELECT sys_context('USERENV','CURRENT_USER') FROM dual;
Output:-
SYS_CONTEXT('USERENV','CURRENT_USER')
-------------------------------------
KNOWP
The above two queries show the only username and don’t give much detail on the current user. To show the current users in the Oracle database we can use the USER_USERS view. This table contains the currently logged user details.
SELECT * FROM user_users;
This view contains the following details:- username, user_id, account_status, lock_date, expiry_date, default_tablespace, temporary_tablespace, local_temp_tablespace, created, initial_rsrc_consumer_group, external_name, proxy_only_connect, common, oracle_maintained, inherited, default_collation, implicit, all_shard, password_change_date.
Table to show the meaning of all columns of DBA_USERS view,
Column | Datatype | NULL | Description |
---|---|---|---|
USERNAME | VARCHAR2(30) | NOT NULL | Name of the user. |
USER_ID | NUMBER | NOT NULL | The ID of the user. |
ACCOUNT_STATUS | VARCHAR2(32) | NOT NULL | Account status of the user. |
LOCK_DATE | DATE | The date on which the account was locked. | |
EXPIRY_DATE | DATE | The expiry date of the user. | |
DEFAULT_TABLESPACE | VARCHAR2(30) | NOT NULL | The default tablespace of the user. |
TEMPORARY_TABLESPACE | VARCHAR2(30) | NOT NULL | The default tablespace for temporary tables. |
CREATED | DATE | NOT NULL | The date on which the user was created. |
INITIAL_RSRC_CONSUMER_GROUP | VARCHAR2(30) | The initial resource consumer group for the user. | |
EXTERNAL_NAME | VARCHAR2(4000) | The external name of the user. |
If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!