1SET(7)                           SQL Commands                           SET(7)
2
3
4

NAME

6       SET - change a run-time parameter
7
8

SYNOPSIS

10       SET [ SESSION | LOCAL ] configuration_parameter { TO | = } { value | 'value' | DEFAULT }
11       SET [ SESSION | LOCAL ] TIME ZONE { timezone | LOCAL | DEFAULT }
12
13

DESCRIPTION

15       The  SET command changes run-time configuration parameters. Many of the
16       run-time parameters listed in in the documentation can be  changed  on-
17       the-fly  with  SET.   (But some require superuser privileges to change,
18       and others cannot be changed after server or session start.)  SET  only
19       affects the value used by the current session.
20
21       If  SET  (or  equivalently  SET SESSION) is issued within a transaction
22       that is later aborted, the effects of the SET  command  disappear  when
23       the  transaction  is  rolled  back. Once the surrounding transaction is
24       committed, the effects will persist  until  the  end  of  the  session,
25       unless overridden by another SET.
26
27       The effects of SET LOCAL last only till the end of the current transac‐
28       tion, whether committed or not. A special case is SET followed  by  SET
29       LOCAL  within  a  single  transaction: the SET LOCAL value will be seen
30       until the end of the transaction, but afterwards (if the transaction is
31       committed) the SET value will take effect.
32
33       The  effects of SET or SET LOCAL are also canceled by rolling back to a
34       savepoint that is earlier than the command.
35
36       If SET LOCAL is used within a function that has a SET  option  for  the
37       same  variable  (see CREATE FUNCTION [create_function(7)]), the effects
38       of the SET LOCAL command disappear at function exit; that is, the value
39       in  effect when the function was called is restored anyway. This allows
40       SET LOCAL to be used for dynamic or repeated  changes  of  a  parameter
41       within  a function, while still having the convenience of using the SET
42       option to save and restore the caller's value. However, a  regular  SET
43       command  overrides  any  surrounding function's SET option; its effects
44       will persist unless rolled back.
45
46              Note: In PostgreSQL versions 8.0 through 8.2, the effects  of  a
47              SET  LOCAL  would be canceled by releasing an earlier savepoint,
48              or by successful exit from  a  PL/pgSQL  exception  block.  This
49              behavior has been changed because it was deemed unintuitive.
50
51

PARAMETERS

53       SESSION
54              Specifies that the command takes effect for the current session.
55              (This is the default if neither SESSION nor LOCAL appears.)
56
57       LOCAL  Specifies that the command takes effect  for  only  the  current
58              transaction. After COMMIT or ROLLBACK, the session-level setting
59              takes effect again. Note that SET LOCAL will appear to  have  no
60              effect if it is executed outside a BEGIN block, since the trans‐
61              action will end immediately.
62
63       configuration_parameter
64              Name of a settable run-time parameter. Available parameters  are
65              documented in in the documentation and below.
66
67       value  New  value  of parameter. Values can be specified as string con‐
68              stants, identifiers, numbers, or comma-separated lists of these,
69              as  appropriate  for  the  particular parameter.  DEFAULT can be
70              written to specify resetting the parameter to its default  value
71              (that  is,  whatever  value it would have had if no SET had been
72              executed in the current session).
73
74       Besides the configuration parameters documented in  in  the  documenta‐
75       tion,  there  are a few that can only be adjusted using the SET command
76       or that have a special syntax:
77
78       SCHEMA SET SCHEMA 'value' is an alias for  SET  search_path  TO  value.
79              Only one schema can be specified using this syntax.
80
81       NAMES  SET NAMES value is an alias for SET client_encoding TO value.
82
83       SEED   Sets  the  internal  seed  for  the random number generator (the
84              function random).  Allowed  values  are  floating-point  numbers
85              between -1 and 1, which are then multiplied by 231-1.
86
87              The seed can also be set by invoking the function setseed:
88
89              SELECT setseed(value);
90
91
92       TIME ZONE
93              SET  TIME  ZONE value is an alias for SET timezone TO value. The
94              syntax SET TIME ZONE allows special syntax  for  the  time  zone
95              specification. Here are examples of valid values:
96
97              'PST8PDT'
98                     The time zone for Berkeley, California.
99
100              'Europe/Rome'
101                     The time zone for Italy.
102
103              -7     The  time zone 7 hours west from UTC (equivalent to PDT).
104                     Positive values are east from UTC.
105
106              INTERVAL '-08:00' HOUR TO MINUTE
107                     The time zone 8 hours west from UTC (equivalent to PST).
108
109              LOCAL
110
111              DEFAULT
112                     Set the time zone to your local time zone (that  is,  the
113                     server's  default value of timezone; if this has not been
114                     explicitly set anywhere, it will be  the  zone  that  the
115                     server's operating system defaults to).
116
117       See in the documentation for more information about time zones.
118

NOTES

120       The  function  set_config provides equivalent functionality; see in the
121       documentation.  Also, it is possible to UPDATE the  pg_settings  system
122       view to perform the equivalent of SET.
123

EXAMPLES

125       Set the schema search path:
126
127       SET search_path TO my_schema, public;
128
129
130       Set the style of date to traditional POSTGRES with ``day before month''
131       input convention:
132
133       SET datestyle TO postgres, dmy;
134
135
136       Set the time zone for Berkeley, California:
137
138       SET TIME ZONE 'PST8PDT';
139
140
141       Set the time zone for Italy:
142
143       SET TIME ZONE 'Europe/Rome';
144
145

COMPATIBILITY

147       SET TIME ZONE extends syntax defined in the SQL standard. The  standard
148       allows  only  numeric  time  zone  offsets while PostgreSQL allows more
149       flexible time-zone specifications. All other  SET  features  are  Post‐
150       greSQL extensions.
151

SEE ALSO

153       RESET [reset(7)], SHOW [show(7)]
154
155
156
157SQL - Language Statements         2014-02-17                            SET(7)
Impressum