1999-07-22 17:09:15 +02:00
|
|
|
<!--
|
2010-09-20 22:08:53 +02:00
|
|
|
doc/src/sgml/ref/set.sgml
|
2001-12-08 04:24:40 +01:00
|
|
|
PostgreSQL documentation
|
1999-07-22 17:09:15 +02:00
|
|
|
-->
|
|
|
|
|
1999-06-04 17:50:44 +02:00
|
|
|
<refentry id="SQL-SET">
|
|
|
|
<refmeta>
|
2010-04-03 09:23:02 +02:00
|
|
|
<refentrytitle>SET</refentrytitle>
|
2008-11-14 11:22:48 +01:00
|
|
|
<manvolnum>7</manvolnum>
|
1999-06-04 17:50:44 +02:00
|
|
|
<refmiscinfo>SQL - Language Statements</refmiscinfo>
|
|
|
|
</refmeta>
|
2003-05-04 04:23:16 +02:00
|
|
|
|
1999-06-04 17:50:44 +02:00
|
|
|
<refnamediv>
|
2000-06-18 23:24:54 +02:00
|
|
|
<refname>SET</refname>
|
2001-09-03 14:57:50 +02:00
|
|
|
<refpurpose>change a run-time parameter</refpurpose>
|
1999-05-20 07:40:27 +02:00
|
|
|
</refnamediv>
|
2003-05-04 04:23:16 +02:00
|
|
|
|
2003-08-31 19:32:24 +02:00
|
|
|
<indexterm zone="sql-set">
|
|
|
|
<primary>SET</primary>
|
|
|
|
</indexterm>
|
|
|
|
|
1999-06-04 17:50:44 +02:00
|
|
|
<refsynopsisdiv>
|
2003-05-04 04:23:16 +02:00
|
|
|
<synopsis>
|
2006-04-25 16:56:04 +02:00
|
|
|
SET [ SESSION | LOCAL ] <replaceable class="PARAMETER">configuration_parameter</replaceable> { TO | = } { <replaceable class="PARAMETER">value</replaceable> | '<replaceable class="PARAMETER">value</replaceable>' | DEFAULT }
|
2002-05-17 03:19:19 +02:00
|
|
|
SET [ SESSION | LOCAL ] TIME ZONE { <replaceable class="PARAMETER">timezone</replaceable> | LOCAL | DEFAULT }
|
2003-05-04 04:23:16 +02:00
|
|
|
</synopsis>
|
2000-06-18 23:24:54 +02:00
|
|
|
</refsynopsisdiv>
|
2010-11-23 21:27:50 +01:00
|
|
|
|
2003-05-04 04:23:16 +02:00
|
|
|
<refsect1>
|
2000-06-18 23:24:54 +02:00
|
|
|
<title>Description</title>
|
2002-05-17 03:19:19 +02:00
|
|
|
|
2000-06-18 23:24:54 +02:00
|
|
|
<para>
|
|
|
|
The <command>SET</command> command changes run-time configuration
|
2003-04-25 21:45:10 +02:00
|
|
|
parameters. Many of the run-time parameters listed in
|
|
|
|
<xref linkend="runtime-config"> can be changed on-the-fly with
|
|
|
|
<command>SET</command>.
|
2003-01-19 01:13:31 +01:00
|
|
|
(But some require superuser privileges to change, and others cannot
|
2003-05-04 04:23:16 +02:00
|
|
|
be changed after server or session start.)
|
2003-01-19 01:13:31 +01:00
|
|
|
<command>SET</command> only affects the value used by the current
|
|
|
|
session.
|
2002-05-17 03:19:19 +02:00
|
|
|
</para>
|
2000-06-18 23:24:54 +02:00
|
|
|
|
2002-05-17 03:19:19 +02:00
|
|
|
<para>
|
2007-09-11 02:06:42 +02:00
|
|
|
If <command>SET</command> (or equivalently <command>SET SESSION</command>)
|
|
|
|
is issued within a transaction that is later aborted, the effects of the
|
2002-05-17 03:19:19 +02:00
|
|
|
<command>SET</command> command disappear when the transaction is rolled
|
2007-09-11 02:06:42 +02:00
|
|
|
back. Once the surrounding transaction is committed, the effects
|
2002-05-17 03:19:19 +02:00
|
|
|
will persist until the end of the session, unless overridden by another
|
|
|
|
<command>SET</command>.
|
|
|
|
</para>
|
2000-06-18 23:24:54 +02:00
|
|
|
|
2002-05-17 03:19:19 +02:00
|
|
|
<para>
|
|
|
|
The effects of <command>SET LOCAL</command> last only till the end of
|
|
|
|
the current transaction, whether committed or not. A special case is
|
|
|
|
<command>SET</command> followed by <command>SET LOCAL</command> within
|
|
|
|
a single transaction: the <command>SET LOCAL</command> value will be
|
|
|
|
seen until the end of the transaction, but afterwards (if the transaction
|
|
|
|
is committed) the <command>SET</command> value will take effect.
|
|
|
|
</para>
|
2007-09-11 02:06:42 +02:00
|
|
|
|
|
|
|
<para>
|
|
|
|
The effects of <command>SET</command> or <command>SET LOCAL</command> are
|
|
|
|
also canceled by rolling back to a savepoint that is earlier than the
|
|
|
|
command.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
If <command>SET LOCAL</command> is used within a function that has a
|
|
|
|
<literal>SET</> option for the same variable (see
|
2010-04-03 09:23:02 +02:00
|
|
|
<xref linkend="sql-createfunction">),
|
2007-09-11 02:06:42 +02:00
|
|
|
the effects of the <command>SET LOCAL</command> command disappear at
|
|
|
|
function exit; that is, the value in effect when the function was called is
|
|
|
|
restored anyway. This allows <command>SET LOCAL</command> to be used for
|
|
|
|
dynamic or repeated changes of a parameter within a function, while still
|
|
|
|
having the convenience of using the <literal>SET</> option to save and
|
|
|
|
restore the caller's value. However, a regular <command>SET</> command
|
|
|
|
overrides any surrounding function's <literal>SET</> option; its effects
|
|
|
|
will persist unless rolled back.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
In <productname>PostgreSQL</productname> versions 8.0 through 8.2,
|
|
|
|
the effects of a <command>SET LOCAL</command> would be canceled by
|
|
|
|
releasing an earlier savepoint, or by successful exit from a
|
|
|
|
<application>PL/pgSQL</application> exception block. This behavior
|
|
|
|
has been changed because it was deemed unintuitive.
|
|
|
|
</para>
|
|
|
|
</note>
|
2003-05-04 04:23:16 +02:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>Parameters</title>
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><literal>SESSION</></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Specifies that the command takes effect for the current session.
|
|
|
|
(This is the default if neither <literal>SESSION</> nor
|
|
|
|
<literal>LOCAL</> appears.)
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><literal>LOCAL</></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Specifies that the command takes effect for only the current
|
|
|
|
transaction. After <command>COMMIT</> or <command>ROLLBACK</>,
|
2013-11-26 01:19:40 +01:00
|
|
|
the session-level setting takes effect again. This has no effect
|
|
|
|
outside of a transaction block.
|
2003-05-04 04:23:16 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2006-04-25 16:56:04 +02:00
|
|
|
<term><replaceable class="PARAMETER">configuration_parameter</replaceable></term>
|
2003-05-04 04:23:16 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Name of a settable run-time parameter. Available parameters are
|
|
|
|
documented in <xref linkend="runtime-config"> and below.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><replaceable class="PARAMETER">value</replaceable></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
New value of parameter. Values can be specified as string
|
|
|
|
constants, identifiers, numbers, or comma-separated lists of
|
2007-09-11 02:06:42 +02:00
|
|
|
these, as appropriate for the particular parameter.
|
|
|
|
<literal>DEFAULT</literal> can be written to specify
|
|
|
|
resetting the parameter to its default value (that is, whatever
|
|
|
|
value it would have had if no <command>SET</> had been executed
|
|
|
|
in the current session).
|
2003-05-04 04:23:16 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
2002-10-09 06:59:38 +02:00
|
|
|
|
2002-05-17 03:19:19 +02:00
|
|
|
<para>
|
2003-05-04 04:23:16 +02:00
|
|
|
Besides the configuration parameters documented in <xref
|
|
|
|
linkend="runtime-config">, there are a few that can only be
|
|
|
|
adjusted using the <command>SET</command> command or that have a
|
|
|
|
special syntax:
|
2002-05-17 03:19:19 +02:00
|
|
|
|
|
|
|
<variablelist>
|
2008-10-27 10:37:47 +01:00
|
|
|
<varlistentry>
|
|
|
|
<term><literal>SCHEMA</literal></term>
|
|
|
|
<listitem>
|
2011-08-07 09:49:45 +02:00
|
|
|
<para><literal>SET SCHEMA '<replaceable>value</>'</> is an alias for
|
2008-10-27 10:37:47 +01:00
|
|
|
<literal>SET search_path TO <replaceable>value</></>. Only one
|
|
|
|
schema can be specified using this syntax.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2000-06-18 23:24:54 +02:00
|
|
|
<varlistentry>
|
2003-05-04 04:23:16 +02:00
|
|
|
<term><literal>NAMES</literal></term>
|
2000-06-18 23:24:54 +02:00
|
|
|
<listitem>
|
2011-08-07 09:49:45 +02:00
|
|
|
<para><literal>SET NAMES <replaceable>value</></> is an alias for
|
2003-05-04 04:23:16 +02:00
|
|
|
<literal>SET client_encoding TO <replaceable>value</></>.
|
2002-05-17 03:19:19 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2003-05-04 04:23:16 +02:00
|
|
|
<term><literal>SEED</literal></term>
|
2002-05-17 03:19:19 +02:00
|
|
|
<listitem>
|
2000-06-18 23:24:54 +02:00
|
|
|
<para>
|
2003-05-04 04:23:16 +02:00
|
|
|
Sets the internal seed for the random number generator (the
|
|
|
|
function <function>random</function>). Allowed values are
|
2008-03-10 13:39:23 +01:00
|
|
|
floating-point numbers between -1 and 1, which are then
|
2003-05-04 04:23:16 +02:00
|
|
|
multiplied by 2<superscript>31</>-1.
|
2002-06-11 17:44:38 +02:00
|
|
|
</para>
|
2000-06-18 23:24:54 +02:00
|
|
|
|
2002-06-11 17:44:38 +02:00
|
|
|
<para>
|
2003-05-04 04:23:16 +02:00
|
|
|
The seed can also be set by invoking the function
|
|
|
|
<function>setseed</function>:
|
|
|
|
<programlisting>
|
2002-05-17 03:19:19 +02:00
|
|
|
SELECT setseed(<replaceable>value</replaceable>);
|
2011-08-07 09:49:45 +02:00
|
|
|
</programlisting></para>
|
2002-06-11 17:44:38 +02:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
1999-07-15 18:31:16 +02:00
|
|
|
|
2002-06-11 17:44:38 +02:00
|
|
|
<varlistentry>
|
2003-05-04 04:23:16 +02:00
|
|
|
<term><literal>TIME ZONE</literal></term>
|
2002-06-11 17:44:38 +02:00
|
|
|
<listitem>
|
2011-08-07 09:49:45 +02:00
|
|
|
<para><literal>SET TIME ZONE <replaceable>value</></> is an alias
|
2003-05-04 04:23:16 +02:00
|
|
|
for <literal>SET timezone TO <replaceable>value</></>. The
|
2003-06-21 21:33:36 +02:00
|
|
|
syntax <literal>SET TIME ZONE</literal> allows special syntax
|
2003-05-04 04:23:16 +02:00
|
|
|
for the time zone specification. Here are examples of valid
|
2004-08-10 02:55:08 +02:00
|
|
|
values:
|
2001-12-29 19:35:54 +01:00
|
|
|
|
|
|
|
<variablelist>
|
2002-06-11 17:44:38 +02:00
|
|
|
<varlistentry>
|
2003-05-04 04:23:16 +02:00
|
|
|
<term><literal>'PST8PDT'</literal></term>
|
2002-06-11 17:44:38 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-05-04 04:23:16 +02:00
|
|
|
The time zone for Berkeley, California.
|
2002-06-11 17:44:38 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
2003-05-04 04:23:16 +02:00
|
|
|
<term><literal>'Europe/Rome'</literal></term>
|
2002-06-11 17:44:38 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-05-04 04:23:16 +02:00
|
|
|
The time zone for Italy.
|
2002-06-11 17:44:38 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
2003-07-17 02:55:37 +02:00
|
|
|
<term><literal>-7</literal></term>
|
2002-06-11 17:44:38 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-06-21 21:33:36 +02:00
|
|
|
The time zone 7 hours west from UTC (equivalent
|
2003-07-17 02:55:37 +02:00
|
|
|
to PDT). Positive values are east from UTC.
|
2002-06-11 17:44:38 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
2003-07-17 02:55:37 +02:00
|
|
|
<term><literal>INTERVAL '-08:00' HOUR TO MINUTE</literal></term>
|
2002-06-11 17:44:38 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-06-21 21:33:36 +02:00
|
|
|
The time zone 8 hours west from UTC (equivalent
|
2002-06-11 17:44:38 +02:00
|
|
|
to PST).
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
2003-05-04 04:23:16 +02:00
|
|
|
<term><literal>LOCAL</literal></term>
|
|
|
|
<term><literal>DEFAULT</literal></term>
|
2002-06-11 17:44:38 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2007-09-11 02:06:42 +02:00
|
|
|
Set the time zone to your local time zone (that is, the
|
2011-09-09 23:59:11 +02:00
|
|
|
server's default value of <varname>timezone</>).
|
2002-06-11 17:44:38 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
2013-11-01 18:57:31 +01:00
|
|
|
</para>
|
2000-03-17 06:29:07 +01:00
|
|
|
|
2013-11-01 18:57:31 +01:00
|
|
|
<para>
|
|
|
|
Timezone settings given as numbers or intervals are internally
|
|
|
|
translated to POSIX timezone syntax. For example, after
|
|
|
|
<literal>SET TIME ZONE -7</>, <command>SHOW TIME ZONE</> would
|
|
|
|
report <literal><-07>+07</>.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2006-09-22 18:20:00 +02:00
|
|
|
See <xref linkend="datatype-timezones"> for more information
|
|
|
|
about time zones.
|
2002-06-11 17:44:38 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
</para>
|
2000-06-18 23:24:54 +02:00
|
|
|
</refsect1>
|
|
|
|
|
2003-03-25 17:15:44 +01:00
|
|
|
<refsect1>
|
|
|
|
<title>Notes</title>
|
|
|
|
|
|
|
|
<para>
|
2003-04-25 21:45:10 +02:00
|
|
|
The function <function>set_config</function> provides equivalent
|
2007-09-11 02:06:42 +02:00
|
|
|
functionality; see <xref linkend="functions-admin">.
|
|
|
|
Also, it is possible to UPDATE the
|
|
|
|
<link linkend="view-pg-settings"><structname>pg_settings</structname></link>
|
|
|
|
system view to perform the equivalent of <command>SET</>.
|
2003-03-25 17:15:44 +01:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
2010-11-23 21:27:50 +01:00
|
|
|
|
2000-06-18 23:24:54 +02:00
|
|
|
<refsect1>
|
|
|
|
<title>Examples</title>
|
2003-05-04 04:23:16 +02:00
|
|
|
|
1999-06-04 17:50:44 +02:00
|
|
|
<para>
|
2003-05-04 04:23:16 +02:00
|
|
|
Set the schema search path:
|
|
|
|
<programlisting>
|
|
|
|
SET search_path TO my_schema, public;
|
|
|
|
</programlisting>
|
2002-04-21 21:02:39 +02:00
|
|
|
</para>
|
1999-07-06 19:17:31 +02:00
|
|
|
|
2002-04-21 21:02:39 +02:00
|
|
|
<para>
|
2003-05-04 04:23:16 +02:00
|
|
|
Set the style of date to traditional
|
2003-07-29 02:03:19 +02:00
|
|
|
<productname>POSTGRES</productname> with <quote>day before month</>
|
|
|
|
input convention:
|
2003-05-04 04:23:16 +02:00
|
|
|
<screen>
|
2003-07-29 02:03:19 +02:00
|
|
|
SET datestyle TO postgres, dmy;
|
2003-05-04 04:23:16 +02:00
|
|
|
</screen>
|
2002-04-21 21:02:39 +02:00
|
|
|
</para>
|
1999-07-06 19:17:31 +02:00
|
|
|
|
2002-04-21 21:02:39 +02:00
|
|
|
<para>
|
2004-08-10 02:55:08 +02:00
|
|
|
Set the time zone for Berkeley, California:
|
2003-05-04 04:23:16 +02:00
|
|
|
<screen>
|
|
|
|
SET TIME ZONE 'PST8PDT';
|
2004-08-10 02:55:08 +02:00
|
|
|
</screen>
|
|
|
|
</para>
|
2002-10-09 18:27:48 +02:00
|
|
|
|
2004-08-10 02:55:08 +02:00
|
|
|
<para>
|
|
|
|
Set the time zone for Italy:
|
|
|
|
<screen>
|
|
|
|
SET TIME ZONE 'Europe/Rome';
|
2011-08-07 09:49:45 +02:00
|
|
|
</screen></para>
|
1999-06-04 17:50:44 +02:00
|
|
|
</refsect1>
|
1998-12-29 03:24:47 +01:00
|
|
|
|
2003-05-04 04:23:16 +02:00
|
|
|
<refsect1>
|
2000-06-18 23:24:54 +02:00
|
|
|
<title>Compatibility</title>
|
1999-07-15 18:31:16 +02:00
|
|
|
|
2003-05-04 04:23:16 +02:00
|
|
|
<para>
|
|
|
|
<literal>SET TIME ZONE</literal> extends syntax defined in the SQL
|
|
|
|
standard. The standard allows only numeric time zone offsets while
|
|
|
|
<productname>PostgreSQL</productname> allows more flexible
|
|
|
|
time-zone specifications. All other <literal>SET</literal>
|
|
|
|
features are <productname>PostgreSQL</productname> extensions.
|
|
|
|
</para>
|
1999-05-20 07:40:27 +02:00
|
|
|
</refsect1>
|
2002-08-04 05:53:11 +02:00
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>See Also</title>
|
|
|
|
|
2003-05-04 04:23:16 +02:00
|
|
|
<simplelist type="inline">
|
2010-04-03 09:23:02 +02:00
|
|
|
<member><xref linkend="SQL-RESET"></member>
|
|
|
|
<member><xref linkend="SQL-SHOW"></member>
|
2003-05-04 04:23:16 +02:00
|
|
|
</simplelist>
|
2002-08-04 05:53:11 +02:00
|
|
|
</refsect1>
|
1999-06-04 17:50:44 +02:00
|
|
|
</refentry>
|