 |
Index for Section 5 |
|
 |
Alphabetical listing for S |
|
 |
Bottom of page |
|
SET(5)
NAME
SET - change a run-time parameter
SYNOPSIS
SET variable { TO | = } { value | 'value' | DEFAULT }
SET TIME ZONE { 'timezone' | LOCAL | DEFAULT }
INPUTS
variable
A settable run-time parameter.
value
New value of parameter. DEFAULT can be used to specify resetting the
parameter to its default value. Lists of strings are allowed, but more
complex constructs may need to be single or double quoted.
DESCRIPTION
The SET command changes run-time configuration parameters. The following
parameters can be altered:
CLIENT_ENCODING
NAMES
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.
DATESTYLE
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:
ISO
Use ISO 8601-style dates and times (YYYY-MM-DD HH:MM:SS). This is
the default.
SQL
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.
PostgreSQL
Use traditional PostgreSQL format.
German
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.
European
Use dd/mm/yyyy for numeric date representations.
NonEuropean
US
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.
SEED Sets the internal seed for the random number generator.
value
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);
SERVER_ENCODING
Sets the multibyte server encoding.
This option is only available if PostgreSQL was built with multibyte
support.
TIME ZONE
TIMEZONE
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:
'PST8PDT'
Set the time zone for California.
'Portugal'
Set the time zone for Portugal.
'Europe/Rome'
Set the time zone for Italy.
7 Set the time zone to 7 hours offset west from GMT (equivalent to
PDT).
INTERVAL '08:00' HOUR TO MINUTE
Set the time zone to 8 hours offset west from GMT (equivalent to
PST).
LOCAL
DEFAULT
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 [show(5)] to show the current setting of a parameters.
DIAGNOSTICS
SET VARIABLE
Message returned if successful.
ERROR: not a valid option name: name
The parameter you tried to set does not exist.
ERROR: permission denied
You must be a superuser to have access to certain settings.
ERROR: name can only be set at start-up
Some parameters are fixed once the server is started.
EXAMPLES
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
COMPATIBILITY
SQL92
The second syntax shown above (SET TIME ZONE) attempts to mimic SQL92.
However, SQL allows only numeric time zone offsets. All other parameter
settings as well as the first syntax shown above are a PostgreSQL
extension.
 |
Index for Section 5 |
|
 |
Alphabetical listing for S |
|
 |
Top of page |
|