---
title: "SET SESSION AUTHORIZATION"
url: "https://docs.yugabyte.com/stable/api/ysql/the-sql-language/statements/dcl_set_session_authorization/"
---

# SET SESSION AUTHORIZATION

Use the SET SESSION AUTHORIZATION statement to set the current user and session user of the current session to be the specified user.

## 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

- [![Grammar Icon](/icons/file-lines.svg)Grammar](#grammar-1)
- [![Diagram Icon](/icons/diagram.svg)Diagram](#diagram-1)

```output.ebnf
set_session_authorization ::= SET [ SESSION | LOCAL ] SESSION 
                              AUTHORIZATION { role_name | DEFAULT }

reset_session_authorization ::= RESET SESSION AUTHORIZATION
```

#### set\_session\_authorization

SETSESSIONLOCALSESSIONAUTHORIZATION[role\_name](/stable/api/ysql/syntax_resources/grammar_diagrams#role-name)DEFAULT

#### reset\_session\_authorization

RESETSESSIONAUTHORIZATION

## 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.

```plpgsql
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)
```

## See also

- [CREATE ROLE](/stable/api/ysql/the-sql-language/statements/dcl_create_role "CREATE ROLE")
- [GRANT](/stable/api/ysql/the-sql-language/statements/dcl_grant "GRANT")
- [REVOKE](/stable/api/ysql/the-sql-language/statements/dcl_revoke "REVOKE")
