ALTER SESSION

Function

ALTER SESSION defines or modifies the conditions or parameters that affect the current session. Modified session parameters are kept until the current session is disconnected.

Precautions

Syntax

Parameter Description

To modify the description of parameters related to the session, see Parameter Description of the SET syntax.

Examples

Create the ds schema.

CREATE SCHEMA ds;

Set the search path of the schema.

SET SEARCH_PATH TO ds, public;

Set the time/date type to the traditional postgres format (date before month).

SET DATESTYLE TO postgres, dmy;

Set the character code of the current session to UTF8.

ALTER SESSION SET NAMES 'UTF8';

Set the time zone to Berkeley of California.

SET TIME ZONE 'PST8PDT';

Set the time zone to Italy.

SET TIME ZONE 'Europe/Rome';

Set the current schema.

ALTER SESSION SET CURRENT_SCHEMA TO tpcds;

Set XML OPTION to DOCUMENT.

ALTER SESSION SET XML OPTION DOCUMENT;

Create the role joe, and set the session role to joe.

CREATE ROLE joe WITH PASSWORD '{password}';
ALTER SESSION SET SESSION AUTHORIZATION joe PASSWORD '{password}';

Switch to the default user.

ALTER SESSION SET SESSION AUTHORIZATION default;

Helpful Links

SET