> For the complete documentation index, see [llms.txt](https://docs.starrocks.io/llms.txt). This page is also available as Markdown at its `.md` URL.

# EXECUTE AS

Use the IMPERSONATE privilege with EXECUTE AS statements to switch the execution context of the current session to the impersonated user.

This command is supported from v2.4.

## Syntax[​](#syntax "Direct link to Syntax")

```sql
EXECUTE AS user WITH NO REVERT

```

## Parameters[​](#parameters "Direct link to Parameters")

`user`: The user must already exist.

## Usage notes[​](#usage-notes "Direct link to Usage notes")

* The current login user (who calls the EXECUTE AS statement) must be granted the privilege to impersonate another user. For more information, see [GRANT](https://docs.starrocks.io/docs/sql-reference/sql-statements/account-management/GRANT.md).
* The EXECUTE AS statement must contain the WITH NO REVERT clause, which means the execution context of the current session cannot be switched back to the original login user before the current session ends.

## Examples[​](#examples "Direct link to Examples")

Switch the execution context of the current session to the user `test2`.

```sql
EXECUTE AS test2 WITH NO REVERT;

```

After the switch succeeds, you can run the `select current_user()` command to obtain the current user.

```sql
select current_user();
+-----------------------------+
| CURRENT_USER()              |
+-----------------------------+
| 'default_cluster:test2'@'%' |
+-----------------------------+

```
