> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# EXECUTE AS

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

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

```SQL theme={null}
EXECUTE AS user WITH NO REVERT
```

## Parameters

`user`: The user must already exist.

## 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](/documents/4.2/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

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

```SQL theme={null}
EXECUTE AS test2 WITH NO REVERT;
```

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

```SQL theme={null}
select current_user();
+-----------------------------+
| CURRENT_USER()              |
+-----------------------------+
| 'test2'@'%' |
+-----------------------------+
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.