|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /proc/self/root/usr/share/doc/postgresql-8.1.9/html/ |
Upload File : |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>SET</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 8.1.9 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="SQL Commands"
HREF="sql-commands.html"><LINK
REL="PREVIOUS"
TITLE="SELECT INTO"
HREF="sql-selectinto.html"><LINK
REL="NEXT"
TITLE="SET CONSTRAINTS"
HREF="sql-set-constraints.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2007-04-20T04:40:08"></HEAD
><BODY
CLASS="REFENTRY"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
>PostgreSQL 8.1.9 Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="sql-selectinto.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="sql-selectinto.html"
>Fast Backward</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
HREF="sql-set-constraints.html"
>Fast Forward</A
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
HREF="sql-set-constraints.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="SQL-SET"
></A
>SET</H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN48595"
></A
><H2
>Name</H2
>SET -- change a run-time parameter</DIV
><A
NAME="AEN48598"
></A
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN48600"
></A
><H2
>Synopsis</H2
><PRE
CLASS="SYNOPSIS"
>SET [ SESSION | LOCAL ] <TT
CLASS="REPLACEABLE"
><I
>name</I
></TT
> { TO | = } { <TT
CLASS="REPLACEABLE"
><I
>value</I
></TT
> | '<TT
CLASS="REPLACEABLE"
><I
>value</I
></TT
>' | DEFAULT }
SET [ SESSION | LOCAL ] TIME ZONE { <TT
CLASS="REPLACEABLE"
><I
>timezone</I
></TT
> | LOCAL | DEFAULT }</PRE
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN48606"
></A
><H2
>Description</H2
><P
> The <TT
CLASS="COMMAND"
>SET</TT
> command changes run-time configuration
parameters. Many of the run-time parameters listed in
<A
HREF="runtime-config.html"
>Chapter 17</A
> can be changed on-the-fly with
<TT
CLASS="COMMAND"
>SET</TT
>.
(But some require superuser privileges to change, and others cannot
be changed after server or session start.)
<TT
CLASS="COMMAND"
>SET</TT
> only affects the value used by the current
session.
</P
><P
> If <TT
CLASS="COMMAND"
>SET</TT
> or <TT
CLASS="COMMAND"
>SET SESSION</TT
> is issued
within a transaction that is later aborted, the effects of the
<TT
CLASS="COMMAND"
>SET</TT
> command disappear when the transaction is rolled
back. (This behavior represents a change from
<SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> versions prior to 7.3, where
the effects of <TT
CLASS="COMMAND"
>SET</TT
> 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
<TT
CLASS="COMMAND"
>SET</TT
>.
</P
><P
> The effects of <TT
CLASS="COMMAND"
>SET LOCAL</TT
> last only till the end of
the current transaction, whether committed or not. A special case is
<TT
CLASS="COMMAND"
>SET</TT
> followed by <TT
CLASS="COMMAND"
>SET LOCAL</TT
> within
a single transaction: the <TT
CLASS="COMMAND"
>SET LOCAL</TT
> value will be
seen until the end of the transaction, but afterwards (if the transaction
is committed) the <TT
CLASS="COMMAND"
>SET</TT
> value will take effect.
</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN48626"
></A
><H2
>Parameters</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="LITERAL"
>SESSION</TT
></DT
><DD
><P
> Specifies that the command takes effect for the current session.
(This is the default if neither <TT
CLASS="LITERAL"
>SESSION</TT
> nor
<TT
CLASS="LITERAL"
>LOCAL</TT
> appears.)
</P
></DD
><DT
><TT
CLASS="LITERAL"
>LOCAL</TT
></DT
><DD
><P
> Specifies that the command takes effect for only the current
transaction. After <TT
CLASS="COMMAND"
>COMMIT</TT
> or <TT
CLASS="COMMAND"
>ROLLBACK</TT
>,
the session-level setting takes effect again. Note that
<TT
CLASS="COMMAND"
>SET LOCAL</TT
> will appear to have no effect if it is
executed outside a <TT
CLASS="COMMAND"
>BEGIN</TT
> block, since the
transaction will end immediately.
</P
></DD
><DT
><TT
CLASS="REPLACEABLE"
><I
>name</I
></TT
></DT
><DD
><P
> Name of a settable run-time parameter. Available parameters are
documented in <A
HREF="runtime-config.html"
>Chapter 17</A
> and below.
</P
></DD
><DT
><TT
CLASS="REPLACEABLE"
><I
>value</I
></TT
></DT
><DD
><P
> New value of parameter. Values can be specified as string
constants, identifiers, numbers, or comma-separated lists of
these. <TT
CLASS="LITERAL"
>DEFAULT</TT
> can be used to specify
resetting the parameter to its default value.
</P
></DD
></DL
></DIV
><P
> Besides the configuration parameters documented in <A
HREF="runtime-config.html"
>Chapter 17</A
>, there are a few that can only be
adjusted using the <TT
CLASS="COMMAND"
>SET</TT
> command or that have a
special syntax:
<P
></P
></P><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="LITERAL"
>NAMES</TT
></DT
><DD
><P
> <TT
CLASS="LITERAL"
>SET NAMES <TT
CLASS="REPLACEABLE"
><I
>value</I
></TT
></TT
> is an alias for
<TT
CLASS="LITERAL"
>SET client_encoding TO <TT
CLASS="REPLACEABLE"
><I
>value</I
></TT
></TT
>.
</P
></DD
><DT
><TT
CLASS="LITERAL"
>SEED</TT
></DT
><DD
><P
> Sets the internal seed for the random number generator (the
function <CODE
CLASS="FUNCTION"
>random</CODE
>). Allowed values are
floating-point numbers between 0 and 1, which are then
multiplied by 2<SUP
>31</SUP
>-1.
</P
><P
> The seed can also be set by invoking the function
<CODE
CLASS="FUNCTION"
>setseed</CODE
>:
</P><PRE
CLASS="PROGRAMLISTING"
>SELECT setseed(<TT
CLASS="REPLACEABLE"
><I
>value</I
></TT
>);</PRE
><P>
</P
></DD
><DT
><TT
CLASS="LITERAL"
>TIME ZONE</TT
></DT
><DD
><P
> <TT
CLASS="LITERAL"
>SET TIME ZONE <TT
CLASS="REPLACEABLE"
><I
>value</I
></TT
></TT
> is an alias
for <TT
CLASS="LITERAL"
>SET timezone TO <TT
CLASS="REPLACEABLE"
><I
>value</I
></TT
></TT
>. The
syntax <TT
CLASS="LITERAL"
>SET TIME ZONE</TT
> allows special syntax
for the time zone specification. Here are examples of valid
values:
<P
></P
></P><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="LITERAL"
>'PST8PDT'</TT
></DT
><DD
><P
> The time zone for Berkeley, California.
</P
></DD
><DT
><TT
CLASS="LITERAL"
>'Europe/Rome'</TT
></DT
><DD
><P
> The time zone for Italy.
</P
></DD
><DT
><TT
CLASS="LITERAL"
>-7</TT
></DT
><DD
><P
> The time zone 7 hours west from UTC (equivalent
to PDT). Positive values are east from UTC.
</P
></DD
><DT
><TT
CLASS="LITERAL"
>INTERVAL '-08:00' HOUR TO MINUTE</TT
></DT
><DD
><P
> The time zone 8 hours west from UTC (equivalent
to PST).
</P
></DD
><DT
><TT
CLASS="LITERAL"
>LOCAL</TT
><BR><TT
CLASS="LITERAL"
>DEFAULT</TT
></DT
><DD
><P
> Set the time zone to your local time zone (the one that
the server's operating system defaults to).
</P
></DD
></DL
></DIV
><P>
See <A
HREF="datatype-datetime.html"
>Section 8.5</A
> for more information
about time zones. Also, <A
HREF="datetime-appendix.html"
>Appendix B</A
>
has a list of the recognized names for time zones.
</P
></DD
></DL
></DIV
><P>
</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN48721"
></A
><H2
>Notes</H2
><P
> The function <CODE
CLASS="FUNCTION"
>set_config</CODE
> provides equivalent
functionality. See <A
HREF="functions-admin.html"
>Section 9.20</A
>.
</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN48726"
></A
><H2
>Examples</H2
><P
> Set the schema search path:
</P><PRE
CLASS="PROGRAMLISTING"
>SET search_path TO my_schema, public;</PRE
><P>
</P
><P
> Set the style of date to traditional
<SPAN
CLASS="PRODUCTNAME"
>POSTGRES</SPAN
> with <SPAN
CLASS="QUOTE"
>"day before month"</SPAN
>
input convention:
</P><PRE
CLASS="SCREEN"
>SET datestyle TO postgres, dmy;</PRE
><P>
</P
><P
> Set the time zone for Berkeley, California:
</P><PRE
CLASS="SCREEN"
>SET TIME ZONE 'PST8PDT';</PRE
><P>
</P
><P
> Set the time zone for Italy:
</P><PRE
CLASS="SCREEN"
>SET TIME ZONE 'Europe/Rome';</PRE
><P>
</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN48738"
></A
><H2
>Compatibility</H2
><P
> <TT
CLASS="LITERAL"
>SET TIME ZONE</TT
> extends syntax defined in the SQL
standard. The standard allows only numeric time zone offsets while
<SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> allows more flexible
time-zone specifications. All other <TT
CLASS="LITERAL"
>SET</TT
>
features are <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> extensions.
</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN48745"
></A
><H2
>See Also</H2
><A
HREF="sql-reset.html"
><I
>RESET</I
></A
>, <A
HREF="sql-show.html"
><I
>SHOW</I
></A
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="sql-selectinto.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="sql-set-constraints.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>SELECT INTO</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="sql-commands.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>SET CONSTRAINTS</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>