The SET command changes run-time configuration parameters. The following parameters can be altered:
Sets the multibyte client encoding. The specified encoding must be supported by the backend.
This option is only available if PostgreSQL is build with multibyte support.
Choose the date/time representation style. Two separate settings are made: the default date/time output and the interpretation of ambiguous input.
The following are date/time output styles:
Use ISO 8601-style dates and times (YYYY-MM-DD HH:MM:SS). This is the default.
Use Oracle/Ingres-style dates and times. Note that this style has nothing to do with SQL (which mandates ISO 8601 style), the naming of this option is a historical accident.
Use traditional PostgreSQL format.
Use dd.mm.yyyy for numeric date representations.
The following two options determine both a substyle of the "SQL" and "PostgreSQL" output formats and the preferred interpretation of ambiguous date input.
Use dd/mm/yyyy for numeric date representations.
Use mm/dd/yyyy for numeric date representations.
A value for SET DATESTYLE can be one from the first list (output styles), or one from the second list (substyles), or one from each separated by a comma.
Date format initialization may be done by:
Setting the PGDATESTYLE environment variable. If PGDATESTYLE is set in the frontend environment of a client based on libpq, libpq will automatically set DATESTYLE to the value of PGDATESTYLE during connection start-up. |
Running postmaster using the option -o -e to set dates to the European convention. |
The DateStyle option is really only intended for porting applications. To format your date/time values to choice, use the to_char family of functions.
Sets the internal seed for the random number generator.
The value for the seed to be used by the random function. Allowed values are floating-point numbers between 0 and 1, which are then multiplied by 231-1. This product will silently overflow if a number outside the range is used.
The seed can also be set by invoking the setseed SQL function:
SELECT setseed(value);
Sets the multibyte server encoding.
This option is only available if PostgreSQL was built with multibyte support.
Sets the default time zone for your session. Arguments can be an SQL time interval constant, an integer or double precision constant, or a string representing a time zone supported by the host operating system.
The possible values for time zone depends on your operating system. For example, on Linux /usr/share/zoneinfo contains the database of time zones.
Here are some valid values for time zone:
Set the time zone for California.
Set the time zone for Portugal.
Set the time zone for Italy.
Set the time zone to 7 hours offset west from GMT (equivalent to PDT).
Set the time zone to 8 hours offset west from GMT (equivalent to PST).
Set the time zone to your local time zone (the one that your operating system defaults to).
If an invalid time zone is specified, the time zone becomes GMT (on most systems anyway).
If the PGTZ environment variable is set in the frontend environment of a client based on libpq, libpq will automatically set TIMEZONE to the value of PGTZ during connection start-up.
An extended list of other run-time parameters can be found in the Administrator's Guide.
Use SHOW to show the current setting of a parameters.
Message returned if successful.
The parameter you tried to set does not exist.
You must be a superuser to have access to certain settings.
Some parameters are fixed once the server is started.
Set the style of date to traditional PostgreSQL with European conventions:
SET DATESTYLE TO PostgreSQL,European;
Set the time zone for Berkeley, California, using double quotes to preserve the uppercase attributes of the time zone specifier (note that the date/time format is ISO here):
SET TIME ZONE "PST8PDT"; SELECT CURRENT_TIMESTAMP AS today; today ------------------------ 1998-03-31 07:41:21-08
Set the time zone for Italy (note the required single or double quotes to handle the special characters):
SET TIME ZONE 'Europe/Rome'; SELECT CURRENT_TIMESTAMP AS today; today ------------------------ 1998-03-31 17:41:31+02