SET variable { TO | = } { value | 'value' | DEFAULT } |
SET TIME ZONE { 'timezone' | LOCAL | DEFAULT } |
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.
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 was built 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 the 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 "Postgres" 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 2^31-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 available only 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 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 as defined by the operating system.
If an invalid time zone is specified, the time zone becomes GMT.
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 Red Hat Database Administrator and User's Guide.
Use SHOW to show the current setting of a parameters.
Set the style of date to traditional Postgres with European conventions:
SET DATESTYLE TO postgres,European; |
SET TIME ZONE "PST"; SELECT CURRENT_TIMESTAMP AS today; today ------------------------ 2002-08-09 02:42:34.299322+00 |
SET TIME ZONE 'CET'; SELECT CURRENT_TIMESTAMP AS today; today ------------------------ 2002-08-09 04:42:34.3.6181+02 |