SET SESSION AUTHORIZATION
This page documents a preview version.
v2.23 Preview
Preview includes features under active development and is for development and testing only.
For production, use the latest stable version (v2024.1).
For production, use the latest stable version (v2024.1).
Synopsis
Use the SET SESSION AUTHORIZATION
statement to set the current user and session user of the current session to be the specified user.
Syntax
set_session_authorization ::= SET [ SESSION | LOCAL ] SESSION
AUTHORIZATION { role_name | DEFAULT }
reset_session_authorization ::= RESET SESSION AUTHORIZATION
Semantics
Session user can only be changed by superusers.
Once the session user is set to role_name
, any further SQL commands will use the privileges available to that role.
To reset the session user back to current authenticated user, RESET SESSION AUTHORIZATION
or SET SESSION AUTHORIZATION DEFAULT
can be used.
Examples
- Set session user to John.
yugabyte=# select session_user, current_user;
session_user | current_user
--------------+--------------
yugabyte | yugabyte
(1 row)
yugabyte=# set session authorization john;
SET
yugabyte=# select session_user, current_user;
session_user | current_user
--------------+--------------
john | john
(1 row)