SHOW DEFAULT SESSION VARIABLES FOR ROLE

On this page Carat arrow pointing down

The SHOW DEFAULT SESSION VARIABLES FOR ROLE statement lists the values for updated session variables that are applied to a given user or role.

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.

Synopsis

SHOW DEFAULT SESSION VARIABLES FOR role_or_group_or_user role_spec ROLE_ALL USER_ALL ALL

Parameters

Parameter Description
FOR {role_or_group_or_user} The user, group, or role whose updated session variables should be displayed.
FOR ROLE ALL Denotes that changes to default session variables across all roles should be displayed.
FOR USER ALL Alias for FOR ROLE ALL.

Response

Column Description
session_variables The name of the session variable that has had its default value changed.
default_values The updated value of the session variable.
database The database 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.

Required Privileges

The user issuing this statement must have at least one of the following 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:

icon/buttons/copy
SHOW DEFAULT SESSION VARIABLES FOR ROLE public;
SHOW DEFAULT SESSION VARIABLES FOR ROLE 0

Another way of confirming zero rows of output:

icon/buttons/copy
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

icon/buttons/copy
CREATE USER movr_auditor;
icon/buttons/copy
ALTER ROLE ALL SET application_name = 'movr';
icon/buttons/copy
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

icon/buttons/copy
CREATE DATABASE movr_audit;
icon/buttons/copy
ALTER ROLE ALL IN DATABASE movr_audit SET application_name = 'movr_audit';
icon/buttons/copy
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

icon/buttons/copy
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

icon/buttons/copy
\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


Yes No
On this page

Yes No