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

# SHOW DEFAULT SESSION VARIABLES FOR ROLE

The `SHOW DEFAULT SESSION VARIABLES FOR ROLE` [statement](https://docs.cockroachlabs.com/docs/stable/sql-statements.md) lists the values for updated [session variables](https://docs.cockroachlabs.com/docs/stable/set-vars.md) that are applied to a given [user or role](https://docs.cockroachlabs.com/docs/stable/security-reference/authorization.md#roles).

The results returned only include the values of session variables that are changed from the defaults. When no session variables have been changed from the defaults for a given role, the statement [returns no values](#output-when-no-session-variables-have-been-changed).

## Synopsis

![show\_default\_session\_variables\_for\_role syntax diagram](https://mintcdn.com/cockroachlabs/UZNSFbmU2EwEm6G5/images/sql-diagrams/common/show_default_session_variables_for_role.svg?fit=max\&auto=format\&n=UZNSFbmU2EwEm6G5\&q=85\&s=5428fd39c01b3d6687548d7c4191cccc)

## Parameters

| Parameter | Description |
| - | - |
| `FOR {role_or_group_or_user}` | The [user, group, or role](https://docs.cockroachlabs.com/docs/stable/security-reference/authorization.md#roles) whose updated [session variables](https://docs.cockroachlabs.com/docs/stable/session-variables.md) should be displayed. |
| `FOR ROLE ALL` | Denotes that changes to default [session variables](https://docs.cockroachlabs.com/docs/stable/session-variables.md) across all [roles](https://docs.cockroachlabs.com/docs/stable/security-reference/authorization.md#roles) should be displayed. |
| `FOR USER ALL` | Alias for `FOR ROLE ALL`. |

## Response

| Column | Description |
| - | - |
| `session_variables` | The name of the [session variable](https://docs.cockroachlabs.com/docs/stable/session-variables.md) that has had its default value changed. |
| `default_values` | The updated value of the [session variable](https://docs.cockroachlabs.com/docs/stable/session-variables.md). |
| `database` | The [database](https://docs.cockroachlabs.com/docs/stable/show-databases.md) where the change to the session variable will be applied. |
| `inherited_globally` | Whether the change to the variable's value is applied to all users. For more information, see [`ALTER ROLE ALL`](https://docs.cockroachlabs.com/docs/stable/alter-role#set-default-session-variable-values-for-all-users). |

## Required privileges

The [user](https://docs.cockroachlabs.com/docs/stable/security-reference/authorization.md#sql-users) issuing this statement must have at least one of the following [privileges](https://docs.cockroachlabs.com/docs/stable/security-reference/authorization.md#privileges):

* `CREATEROLE`
* `MODIFYCLUSTERSETTING`
* `MODIFYSQLCLUSTERSETTING`

## Examples

### Output when no session variables have been changed

When no session variables have been changed from the defaults for a given role, the statement returns no values:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW DEFAULT SESSION VARIABLES FOR ROLE public;
```

```
SHOW DEFAULT SESSION VARIABLES FOR ROLE 0
```

Another way of confirming zero rows of output:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SELECT * FROM [SHOW DEFAULT SESSION VARIABLES FOR ROLE public];
```

```
  session_variables | default_values | database | inherited_globally
--------------------+----------------+----------+---------------------
(0 rows)
```

### Show changed session variables that apply to a user

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
CREATE USER movr_auditor;
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
ALTER ROLE ALL SET application_name = 'movr';
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW DEFAULT SESSION VARIABLES FOR ROLE movr_auditor;
```

```
  session_variables | default_values | database | inherited_globally
--------------------+----------------+----------+---------------------
  application_name  | movr           | NULL     |         t
(1 row)
```

### Show changed session variables that apply to a user in different databases

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
CREATE DATABASE movr_audit;
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
ALTER ROLE ALL IN DATABASE movr_audit SET application_name = 'movr_audit';
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW DEFAULT SESSION VARIABLES FOR ROLE movr_auditor;
```

```
  session_variables | default_values |  database  | inherited_globally
--------------------+----------------+------------+---------------------
  application_name  | movr_audit     | movr_audit |         t
  application_name  | movr           | NULL       |         t
(2 rows)
```

### Show updated default session variables that apply to all users

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW DEFAULT SESSION VARIABLES FOR ROLE ALL;
```

```
  session_variables | default_values |  database
--------------------+----------------+-------------
  application_name  | movr_audit     | movr_audit
  application_name  | movr           | NULL
(2 rows)
```

### Get inline help in the SQL shell

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
\h SHOW DEFAULT SESSION VARIABLES FOR ROLE
```

```
Command:     SHOW DEFAULT SESSION VARIABLES FOR ROLE
Description: list default session variables for role
Category:    privileges and security
Syntax:
SHOW DEFAULT SESSION VARIABLES FOR ROLE <name>
```

## See also

* [`ALTER ROLE ALL`](https://docs.cockroachlabs.com/docs/stable/alter-role#set-default-session-variable-values-for-all-users)
* [Session Variables](https://docs.cockroachlabs.com/docs/stable/session-variables.md)
* [`SHOW {session variable}`](https://docs.cockroachlabs.com/docs/stable/show-vars)
* [SQL Statements](https://docs.cockroachlabs.com/docs/stable/sql-statements.md)
* [Default Privileges](https://docs.cockroachlabs.com/docs/stable/security-reference/authorization.md#default-privileges)
