Please take this survey to help us learn more about how you use third party tools. Your input is greatly appreciated!

Find session user

Hello everyone! I hope this is not a repost but I honestly lost hope in finding an answer on my own :/ May I know I can track who the session user is? Thanks so much for your time.

Comments

  • moshegmosheg Employee
    SELECT CURRENT_USER;
     current_user
    --------------
     dbadmin
    (1 row)
    
    \c - user01
    You are now connected as user "user01".
    
    SELECT CURRENT_USER;
     current_user
    --------------
     user01
    (1 row)
    
  • Jim_KnicelyJim_Knicely Administrator

    You can also call any of these functions:

    dbadmin=> SELECT user, username(), session_user();
     current_user | username | session_user
    --------------+----------+--------------
     dbadmin      | dbadmin  | dbadmin
    (1 row)
    
    dbadmin=> CREATE USER jimcarter;
    CREATE USER
    
    dbadmin=> \c - jimcarter
    You are now connected as user "jimcarter".
    
    dbadmin=> SELECT user, username(), session_user();
     current_user | username  | session_user
    --------------+-----------+--------------
     jimcarter    | jimcarter | jimcarter
    (1 row)
    

    Or query the SESSIONS and USER_SESSIONS system tables:

    dbadmin=> SELECT user_name FROM sessions WHERE session_id = current_session();
     user_name
    -----------
     jimcarter
    (1 row)
    
    dbadmin=> SELECT user_name FROM user_sessions WHERE session_id = current_session();
     user_name
    -----------
     jimcarter
    (1 row)
    

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file

Can't find what you're looking for? Search the Vertica Documentation, Knowledge Base, or Blog for more information.