Skip to main content
The SET statement can modify one of the session configuration variables. These can also be queried via SHOW.

Supported variables

The following session variables are exposed only for backwards compatibility with earlier CockroachDB releases and have no impact on how CockroachDB runs:

Considerations

Session variable precedence

When a session starts, CockroachDB determines the initial value of each session variable by evaluating the settings in the following order (items earlier in the list take precedence over later items):
  1. Connection string parameters: A value supplied as a query parameter in the connection URL (for example, .../movr?sslmode=disable&timezone=UTC ).
  2. Per-role, per-database defaults: A value set by ALTER ROLE {role_name} IN DATABASE {db_name} SET {var}={value}.
  3. Per-role, all-database defaults: A value set by ALTER ROLE {role_name} SET {var}={value}.
  4. All-role, per-database defaults: A value set by ALTER ROLE ALL IN DATABASE {db_name} SET {var}={value} or equivalently by ALTER DATABASE {db_name} SET {var}={value}.
  5. Cluster-wide defaults for all roles and all databases: A value set by ALTER ROLE ALL SET {var}={value}.
If a session variable is not modified using any of the preceding methods, the built-in system default value is used. Note that the root user is exempt from settings 3–5. The root user is only affected by values specified in the connection string. You can also set session variables for the duration of a single transaction by using SET LOCAL {var}={value}.
Changes to defaults using the preceding methods only apply to future sessions. This is because session variable resolution happens at session start time. To change a default value in an existing open session, set the variable explicitly with SET.

See also