1999-07-22 17:09:15 +02:00
|
|
|
<!--
|
2004-08-10 02:55:08 +02:00
|
|
|
$PostgreSQL: pgsql/doc/src/sgml/ref/set.sgml,v 1.86 2004/08/10 00:55:08 tgl Exp $
|
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>
|
2000-06-18 23:24:54 +02:00
|
|
|
<refentrytitle id="SQL-SET-TITLE">SET</refentrytitle>
|
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>
|
2003-09-22 02:16:58 +02:00
|
|
|
SET [ SESSION | LOCAL ] <replaceable class="PARAMETER">name</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>
|
|
|
|
|
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>
|
|
|
|
If <command>SET</command> or <command>SET SESSION</command> is issued
|
|
|
|
within a transaction that is later aborted, the effects of the
|
|
|
|
<command>SET</command> command disappear when the transaction is rolled
|
|
|
|
back. (This behavior represents a change from
|
|
|
|
<productname>PostgreSQL</productname> versions prior to 7.3, where
|
|
|
|
the effects of <command>SET</command> would not roll back after a later
|
|
|
|
error.) Once the surrounding transaction is committed, the effects
|
|
|
|
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>
|
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</>,
|
|
|
|
the session-level setting takes effect again. Note that
|
|
|
|
<command>SET LOCAL</> will appear to have no effect if it is
|
|
|
|
executed outside a <command>BEGIN</> block, since the
|
|
|
|
transaction will end immediately.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2003-09-22 02:16:58 +02:00
|
|
|
<term><replaceable class="PARAMETER">name</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
|
|
|
|
these. <literal>DEFAULT</literal> can be used to specify
|
|
|
|
resetting the parameter to its default value.
|
|
|
|
</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>
|
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>
|
|
|
|
<para>
|
2003-06-21 21:33:36 +02:00
|
|
|
<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
|
|
|
|
floating-point numbers between 0 and 1, which are then
|
|
|
|
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>);
|
2003-05-04 04:23:16 +02:00
|
|
|
</programlisting>
|
2002-06-11 17:44:38 +02:00
|
|
|
</para>
|
|
|
|
</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>
|
2001-12-29 19:35:54 +01:00
|
|
|
<para>
|
2003-06-21 21:33:36 +02:00
|
|
|
<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>
|
|
|
|
Set the time zone to your local time zone (the one that
|
2003-07-17 02:55:37 +02:00
|
|
|
the server's operating system defaults to).
|
2002-06-11 17:44:38 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
2000-03-17 06:29:07 +01:00
|
|
|
|
2003-05-04 04:23:16 +02:00
|
|
|
See <xref linkend="datatype-datetime"> for more information
|
2004-08-10 02:55:08 +02:00
|
|
|
about time zones. Also, <xref linkend="datetime-appendix">
|
|
|
|
has a list of the recognized names for 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
|
2004-08-03 22:32:36 +02:00
|
|
|
functionality. See <xref linkend="functions-admin">.
|
2003-03-25 17:15:44 +01:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
1999-05-20 07:40:27 +02: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';
|
2003-05-04 04:23:16 +02:00
|
|
|
</screen>
|
1999-07-06 19:17:31 +02:00
|
|
|
</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">
|
|
|
|
<member><xref linkend="SQL-RESET" endterm="SQL-RESET-title"></member>
|
|
|
|
<member><xref linkend="SQL-SHOW" endterm="SQL-SHOW-title"></member>
|
|
|
|
</simplelist>
|
2002-08-04 05:53:11 +02:00
|
|
|
</refsect1>
|
1999-06-04 17:50:44 +02:00
|
|
|
</refentry>
|
1999-05-20 07:40:27 +02:00
|
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
2000-03-31 05:20:17 +02:00
|
|
|
mode:sgml
|
1999-05-20 07:40:27 +02:00
|
|
|
sgml-omittag:nil
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
sgml-parent-document:nil
|
|
|
|
sgml-default-dtd-file:"../reference.ced"
|
|
|
|
sgml-exposed-tags:nil
|
2000-03-31 05:20:17 +02:00
|
|
|
sgml-local-catalogs:("/usr/lib/sgml/catalog")
|
1999-05-20 07:40:27 +02:00
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
-->
|