1SET(7)                   PostgreSQL 14.3 Documentation                  SET(7)
2
3
4

NAME

6       SET - change a run-time parameter
7

SYNOPSIS

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

DESCRIPTION

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

PARAMETERS

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

NOTES

123       The function set_config provides equivalent functionality; see
124       Section 9.27.1. Also, it is possible to UPDATE the pg_settings system
125       view to perform the equivalent of SET.
126

EXAMPLES

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

COMPATIBILITY

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

SEE ALSO

152       RESET(7), SHOW(7)
153
154
155
156PostgreSQL 14.3                      2022                               SET(7)
Impressum