> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-3a82795f.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Documentation for Set Role

# SET ROLE Statement

Activates roles for the current user.

```sql theme={null}
SET ROLE {DEFAULT | NONE | role [,...] | ALL | ALL EXCEPT role [,...]}
```

<h2 id="set-default-role">
  SET DEFAULT ROLE
</h2>

Sets default roles to a user.

Default roles are automatically activated at user login. You can set as default only the previously granted roles. If the role isn't granted to a user, ClickHouse throws an exception.

```sql theme={null}
SET DEFAULT ROLE {NONE | role [,...] | ALL | ALL EXCEPT role [,...]} TO {user|CURRENT_USER} [,...]
```

<h2 id="examples">
  Examples
</h2>

Set multiple default roles to a user:

```sql theme={null}
SET DEFAULT ROLE role1, role2, ... TO user
```

Set all the granted roles as default to a user:

```sql theme={null}
SET DEFAULT ROLE ALL TO user
```

Purge default roles from a user:

```sql theme={null}
SET DEFAULT ROLE NONE TO user
```

Set all the granted roles as default except for specific roles `role1` and `role2`:

```sql theme={null}
SET DEFAULT ROLE ALL EXCEPT role1, role2 TO user
```
