SET

Name

SET  --  Set run-time variables.

Synopsis

SET variable { TO | = } { value | 'value' | DEFAULT }
SET TIME ZONE { 'timezone' | LOCAL | DEFAULT }
  

Parameters

variable

Use this parameter to name the run-time variable you are setting.

value

Use this parameter to supply a new value for the specified variable. Use 'DEFAULT' to reset the variable to its default value.

Results

SET VARIABLE

This message is displayed if the variable is successfully set.

ERROR: not a valid option name:(name)

This error is displayed if you try to set a variable that doesn't exist.

ERROR: permission denied

This error is displayed if you do not have adequate permissions to alter the specified variable.

ERROR: name can only be set at start-up

This error is displayed if you attempt to set a variable that can only bet set upon startup.

Description

Use the SET command to modify PostgreSQL run-time configuration variables. The following variable can be altered.

CLIENT_ENCODING, NAMES

This variable sets the multi-byte client encoding scheme.

DATESTYLE

This variable sets the date and time representation style. When setting this variable, you can choose one format from the normal output styles, one of the two substyles, or both an output style and a substyle. Initialization of the format can be performed by manually changing the PGDATESTYLE environment variable, or running postmaster with -o -e to set dates to the European format.

The following are valid date and time output styles.

ISO

ISO 8601 style date and time formatting. Date and time are displayed as YYYY-MM-DD HH:MM:SS. This is the default style.

SQL

Oracle/Ingres style date and time formatting. Despite this format's label, it is not the SQL default; SQL uses ISO 8601 style formatting.

Postgres

Traditional PostgreSQL date and time formatting.

German

German style formatting. Numeric date representations are displayed as DD.MM.YYYY.

European

European style formatting. This is a substyle of the "SQL" and "PostgreSQL" styles. Numeric date representations are displayed as DD/MM/YYYY.

NonEuropean, US

United States style formatting. This is a substyle of the "SQL" and "Postgres" styles. Numeric date representations are displayed as MM/DD/YYYY.

SEED

This variable sets the internal seed for the PostgreSQL random number generator.

value

This value specifies the seed to be used by the random function. Allowed values are floating point numbers between 0 and 1. The number you supply is then multiplied by 2^31-1.

Alternatively, you may set the seed by calling the SQL setseed command, such as: SELECT setseed(value);.

value

This value specifies the seed to be used by the random function. Allowed values are floating point numbers between 0 and 1. The number you supply is then multiplied by 2^31-1.

Alternatively, you may set the seed by calling the SQL setseed command, such as: SELECT setseed(value);.

SERVER_ENCODING

This variable sets the multi-byte server encoding.

TIME ZONE, TIMEZONE

This variable sets the time zone. The available options for this variable are dependent upon your operating system. On a linux machine, the time zone data would probably be stored in /usr/lib/zoneinfo. Whatever the available settings on your system are, the following entries should be valid for use with this keyword,

PST8PDT

Set time zone to California.

Portugal

Sets time zone to Portugal.

'Europe/Rome'

Sets time zone to Italy.

LOCAL, DEFAULT

This sets the time zone to your local time zone. This is the default system time zone.

Examples

The following examples set the date and time display styles.

This example sets the DATESTYLE variable to use traditional PostgreSQL style formatting. It also sets the sub-style to US, which uses additional United States-specific formatting.

 
SET DATESTYLE TO Postgres,US;

The next example sets the date and time formatting to ISO.

SET DATESTYLE TO ISO;