set.sgml 23.1 KB
Newer Older
1
<!--
T
Tom Lane 已提交
2
$Header: /cvsroot/pgsql/doc/src/sgml/ref/set.sgml,v 1.35 2000/03/31 17:45:32 tgl Exp $
3 4 5
Postgres documentation
-->

6 7
<refentry id="SQL-SET">
 <refmeta>
8
  <refentrytitle id="SQL-SET-TITLE">
9
   SET
10 11 12 13
  </refentrytitle>
  <refmiscinfo>SQL - Language Statements</refmiscinfo>
 </refmeta>
 <refnamediv>
14
  <refname>
15
   SET
16 17
  </refname>
  <refpurpose>
18
   Set run-time parameters for session
19
  </refpurpose>
20
 </refnamediv>
21 22
 <refsynopsisdiv>
  <refsynopsisdivinfo>
23
   <date>1999-07-20</date>
24 25
  </refsynopsisdivinfo>
  <synopsis>
26
SET <replaceable class="PARAMETER">variable</replaceable> { TO | = } { <replaceable class="PARAMETER">value</replaceable> | '<replaceable class="PARAMETER">value</replaceable>' | DEFAULT }
27
SET TIME ZONE { '<replaceable class="PARAMETER">timezone</replaceable>' | LOCAL | DEFAULT }
28
SET TRANSACTION ISOLATION LEVEL { READ COMMITTED | SERIALIZABLE }
29
  </synopsis>
30

31 32 33 34 35
  <refsect2 id="R2-SQL-SET-1">
   <refsect2info>
    <date>1998-09-24</date>
   </refsect2info>
   <title>
36
    Inputs
37 38
   </title>
   <para>
39
		
40 41
    <variablelist>
     <varlistentry>
42
      <term><replaceable class="PARAMETER">variable</replaceable></term>
43
      <listitem>
44 45 46 47 48 49
       <para>
	Settable global parameter.
       </para>
      </listitem>
     </varlistentry>
     <varlistentry>
50
      <term><replaceable class="PARAMETER">value</replaceable></term>
51
      <listitem>
52
       <para>
53
	New value of parameter.  <option>DEFAULT</option> can be
54 55 56
	used to specify resetting the parameter to its default
	value. Lists of strings are allowed, but more complex
	constructs may need to be single or double quoted.
57 58 59 60 61
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
   </para>
62

63 64
   <para>
    The possible variables and allowed values are:
65
		
66 67
    <variablelist>
     <varlistentry>
68
      <term>CLIENT_ENCODING | NAMES</term>
69 70
      <listitem>
       <para>
71
	Sets the multi-byte client encoding. Parameters are:
72
	
73 74
	<variablelist>
	 <varlistentry>
75
	  <term><replaceable class="parameter">value</replaceable></term>
76 77 78 79 80 81 82 83 84 85 86 87
	  <listitem>
	   <para>
	    Sets the multi-byte client encoding to
	    <replaceable class="parameter">value</replaceable>.
	    The specified encoding must be supported by the backend.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>

       <para>
88 89
	This option is only available if MULTIBYTE support was enabled
	during the configure step of building Postgres.
90 91 92 93 94
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
95
      <term>DateStyle</term>
96 97
      <listitem>
       <para>
98 99 100
	Set the date/time representation style. Affects the output format,
	and in some cases it can affect the interpretation of input.

101 102
	<variablelist>
	 <varlistentry>
103
	  <term>ISO</term>
104 105
	  <listitem>
	   <para>
106 107 108 109
	    use ISO 8601-style dates and times
	   </para>
	  </listitem>
	 </varlistentry>
110
	 <varlistentry>
111
	  <term>SQL</term>
112 113
	  <listitem>
	   <para>
114 115 116 117
	    use Oracle/Ingres-style dates and times
	   </para>
	  </listitem>
	 </varlistentry>
118
	 <varlistentry>
119
	  <term>Postgres</term>
120 121
	  <listitem>
	   <para>
122 123 124 125
	    use traditional <productname>Postgres</productname> format
	   </para>
	  </listitem>
	 </varlistentry>
126
	 <varlistentry>
127
	  <term>European</term>
128 129
	  <listitem>
	   <para>
130
	    use <literal>dd/mm/yyyy</literal> for numeric date representations.
131 132 133
	   </para>
	  </listitem>
	 </varlistentry>
134
	 <varlistentry>
135
	  <term>NonEuropean</term>
136 137
	  <listitem>
	   <para>
138
	    use <literal>mm/dd/yyyy</literal> for numeric date representations.
139 140 141
	   </para>
	  </listitem>
	 </varlistentry>
142
	 <varlistentry>
143
	  <term>German</term>
144 145
	  <listitem>
	   <para>
146
	    use <literal>dd.mm.yyyy</literal> for numeric date representations.
147 148 149
	   </para>
	  </listitem>
	 </varlistentry>
150
	 <varlistentry>
151
	  <term>US</term>
152 153
	  <listitem>
	   <para>
154
	    same as <literal>NonEuropean</literal>
155 156 157
	   </para>
	  </listitem>
	 </varlistentry>
158
	 <varlistentry>
159
	  <term>DEFAULT</term>
160 161
	  <listitem>
	   <para>
162
	    restores the default values (<literal>US,Postgres</literal>)
163 164 165 166 167
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
168 169

       <para>
170
	Date format initialization may be done by:
171 172
	<simplelist>
	 <member>
173
	  Setting the <envar>PGDATESTYLE</envar> environment variable.
174 175 176
	  If PGDATESTYLE is set in the frontend environment of a client
	  based on libpq, libpq will automatically set DATESTYLE to the
	  value of PGDATESTYLE during connection startup.
177 178
	 </member>
	 <member>
179
	  Running postmaster using the option <option>-o -e</option> to set
180
	  dates to the <literal>European</literal> convention.
181
	  Note that this affects only some combinations of date styles; for example
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
	  the ISO style is not affected by this parameter.
	 </member>
	 <member>
	  Changing variables in 
	  <filename>src/backend/utils/init/globals.c</filename>.
	 </member>
	</simplelist>
       </para>
       <para>
	The variables in <filename>globals.c</filename> which can be changed are:
	<simplelist>
	 <member>
	  bool EuroDates = false | true
	 </member>
	 <member>
	  int  DateStyle = USE_ISO_DATES | USE_POSTGRES_DATES | USE_SQL_DATES | USE_GERMAN_DATES
	 </member>
	</simplelist>
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
205
      <term>SERVER_ENCODING</term>
206 207 208 209 210 211
      <listitem>
       <para>
	Sets the multi-byte server encoding
	
	<variablelist>
	 <varlistentry>
212
	  <term><replaceable class="parameter">value</replaceable></term>
213 214
	  <listitem>
	   <para>
215
	    Sets the multi-byte server encoding.
216 217 218 219 220
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
221

222
       <para>
223 224
	This option is only available if MULTIBYTE support was enabled
	during the configure step of building Postgres.
225
       </para>
226 227 228 229
      </listitem>
     </varlistentry>

     <varlistentry>
230
      <term>TIMEZONE</term>
231 232 233 234 235 236 237 238
      <listitem>
       <para>
	The possible values for timezone depends on your operating
	system. For example on Linux /usr/lib/zoneinfo contains the
	database of timezones.
       </para>
       <para>
	Here are some valid values for timezone:
239
				
240 241
	<variablelist>
	 <varlistentry>
242
	  <term>PST8PDT</term>
243 244 245 246 247 248 249
	  <listitem>
	   <para>
	    set the timezone for California
	   </para>
	  </listitem>
	 </varlistentry>
	 <varlistentry>
250
	  <term>Portugal</term>
251 252 253 254 255 256 257
	  <listitem>
	   <para>
	    set time zone for Portugal.
	   </para>
	  </listitem>
	 </varlistentry>
	 <varlistentry>
258
	  <term>'Europe/Rome'</term>
259 260 261 262 263 264 265
	  <listitem>
	   <para>
	    set time zone for Italy.
	   </para>
	  </listitem>
	 </varlistentry>
	 <varlistentry>
266
	  <term>DEFAULT</term>
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
	  <listitem>
	   <para>
	    set time zone to your local timezone
	    (value of the TZ environment variable).
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
       <para>
	If an invalid time zone is specified, the time zone
	becomes GMT (on most systems anyway).
       </para>
       <para>
	The second syntax shown above, allows one to set the timezone
	with a syntax similar to SQL92 <command>SET TIME ZONE</command>.
	The LOCAL keyword is just an alternate form
	of DEFAULT for SQL92 compatibility.
       </para>
286 287 288 289 290
       <para>
        If the PGTZ environment variable is set in the frontend
	environment of a client based on libpq, libpq will automatically
	set TIMEZONE to the value of PGTZ during connection startup.
       </para>
291 292
      </listitem>
     </varlistentry>
293 294

     <varlistentry>
295
      <term>TRANSACTION ISOLATION LEVEL</term>
296 297 298 299 300 301
      <listitem>
       <para>
	Sets the isolation level for the current transaction.
	
	<variablelist>
	 <varlistentry>
302
	  <term>READ COMMITTED</term>
303 304
	  <listitem>
	   <para>
V
Vadim B. Mikheev 已提交
305 306
	    The current transaction queries read only rows committed
	    before a query began. READ COMMITTED is the default.
307
	   </para>
V
Vadim B. Mikheev 已提交
308 309

	   <note>
310
	   <para>
V
Vadim B. Mikheev 已提交
311 312
	    <acronym>SQL92</acronym> standard requires 
	    SERIALIZABLE to be the default isolation level.
313
	   </para>
V
Vadim B. Mikheev 已提交
314
	   </note>
315 316 317 318
	  </listitem>
	 </varlistentry>
	 
	 <varlistentry>
319
	  <term>SERIALIZABLE</term>
320 321
	  <listitem>
	   <para>
V
Vadim B. Mikheev 已提交
322 323 324 325
	    The current transaction queries read only rows committed
	    before first DML statement 
	    (<command>SELECT/INSERT/DELETE/UPDATE/FETCH/COPY_TO</command>)
	    was executed in this transaction. 
326 327 328
	   </para>
	  </listitem>
	 </varlistentry>
V
Vadim B. Mikheev 已提交
329
	 
330 331 332 333
	</variablelist>
       </para>
      </listitem>
     </varlistentry>
334 335
    </variablelist>
   </para>
336

337 338 339 340 341 342 343
   <para>
    There are also several internal or optimization
    parameters which can be specified
    by the <command>SET</command> command:
    
    <variablelist>
     <varlistentry>
344
      <term>RANDOM_PAGE_COST</term>
345 346
      <listitem>
       <para>
347 348 349
        Sets the optimizer's estimate of the cost of a nonsequentially
	fetched disk page.  This is measured as a multiple of the cost
	of a sequential page fetch.
350 351 352
	
	<variablelist>
	 <varlistentry>
353
	  <term><replaceable class="parameter">float8</replaceable></term>
354 355
	  <listitem>
	   <para>
356 357
	    Set the cost of a random page access
	    to the specified floating-point value.
358 359 360
	   </para>
	  </listitem>
	 </varlistentry>
361 362 363 364 365 366 367 368 369 370 371 372 373 374
	</variablelist>
       </para>
      </listitem>
     </varlistentry>
    
     <varlistentry>
      <term>CPU_TUPLE_COST</term>
      <listitem>
       <para>
        Sets the optimizer's estimate of the cost of processing each
	tuple during a query.  This is measured as a fraction of the cost
	of a sequential page fetch.
	
	<variablelist>
375
	 <varlistentry>
376
	  <term><replaceable class="parameter">float8</replaceable></term>
377 378
	  <listitem>
	   <para>
379 380
	    Set the cost of per-tuple CPU processing
	    to the specified floating-point value.
381 382 383 384 385
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
386 387 388 389 390 391
      </listitem>
     </varlistentry>
    
     <varlistentry>
      <term>CPU_INDEX_TUPLE_COST</term>
      <listitem>
392
       <para>
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
        Sets the optimizer's estimate of the cost of processing each
	index tuple during an index scan.  This is measured as a fraction
	of the cost of a sequential page fetch.
	
	<variablelist>
	 <varlistentry>
	  <term><replaceable class="parameter">float8</replaceable></term>
	  <listitem>
	   <para>
	    Set the cost of per-index-tuple CPU processing
	    to the specified floating-point value.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
      </listitem>
     </varlistentry>
    
     <varlistentry>
      <term>CPU_OPERATOR_COST</term>
      <listitem>
       <para>
        Sets the optimizer's estimate of the cost of processing each
	operator in a WHERE clause.  This is measured as a fraction
	of the cost of a sequential page fetch.
	
	<variablelist>
	 <varlistentry>
	  <term><replaceable class="parameter">float8</replaceable></term>
	  <listitem>
	   <para>
	    Set the cost of per-operator CPU processing
	    to the specified floating-point value.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
      </listitem>
     </varlistentry>
    
     <varlistentry>
      <term>EFFECTIVE_CACHE_SIZE</term>
      <listitem>
       <para>
        Sets the optimizer's assumption about the effective size of the
	disk cache (that is, the portion of the kernel's disk cache that
	will be used for Postgres data files).  This is measured in disk
	pages, which are normally 8Kb apiece.
	
	<variablelist>
	 <varlistentry>
	  <term><replaceable class="parameter">float8</replaceable></term>
	  <listitem>
	   <para>
	    Set the assumed cache size
	    to the specified floating-point value.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
455 456 457
       </para>
      </listitem>
     </varlistentry>
458

459
     <varlistentry>
460
      <term>ENABLE_SEQSCAN</term>
461 462
      <listitem>
       <para>
463 464 465 466
        Enables or disables the planner's use of sequential scan plan types.
	(It's not possible to suppress sequential scans entirely, but turning
	this variable OFF discourages the planner from using one if there is
	any other method available.)
467

468
	<variablelist>
469
	 <varlistentry>
470
	  <term>ON</term>
471 472
	  <listitem>
	   <para>
473
	    enables use of sequential scans (default setting).
474 475 476
	   </para>
	  </listitem>
	 </varlistentry>
477
	
478
	 <varlistentry>
479
	  <term>OFF</term>
480 481
	  <listitem>
	   <para>
482
	    disables use of sequential scans.
483 484 485 486
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
487
       </para>
488 489
      </listitem>
     </varlistentry>
490

491 492 493
     <varlistentry>
      <term>ENABLE_INDEXSCAN</term>
      <listitem>
494
       <para>
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515
        Enables or disables the planner's use of index scan plan types.

	<variablelist>
	 <varlistentry>
	  <term>ON</term>
	  <listitem>
	   <para>
	    enables use of index scans (default setting).
	   </para>
	  </listitem>
	 </varlistentry>
	
	 <varlistentry>
	  <term>OFF</term>
	  <listitem>
	   <para>
	    disables use of index scans.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
516 517 518
       </para>
      </listitem>
     </varlistentry>
519 520

     <varlistentry>
521
      <term>ENABLE_TIDSCAN</term>
522 523
      <listitem>
       <para>
524
        Enables or disables the planner's use of TID scan plan types.
525

526 527
	<variablelist>
	 <varlistentry>
528
	  <term>ON</term>
529 530
	  <listitem>
	   <para>
531
	    enables use of TID scans (default setting).
532 533 534
	   </para>
	  </listitem>
	 </varlistentry>
535 536 537 538 539 540 541 542 543 544 545 546 547
	
	 <varlistentry>
	  <term>OFF</term>
	  <listitem>
	   <para>
	    disables use of TID scans.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
      </listitem>
     </varlistentry>
548

549 550 551 552 553 554 555 556 557 558
     <varlistentry>
      <term>ENABLE_SORT</term>
      <listitem>
       <para>
        Enables or disables the planner's use of explicit sort steps.
	(It's not possible to suppress explicit sorts entirely, but turning
	this variable OFF discourages the planner from using one if there is
	any other method available.)

	<variablelist>
559
	 <varlistentry>
560
	  <term>ON</term>
561 562
	  <listitem>
	   <para>
563
	    enables use of sorts (default setting).
564 565 566
	   </para>
	  </listitem>
	 </varlistentry>
567 568 569 570 571 572 573 574 575 576 577 578 579
	
	 <varlistentry>
	  <term>OFF</term>
	  <listitem>
	   <para>
	    disables use of sorts.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
      </listitem>
     </varlistentry>
580

581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599
     <varlistentry>
      <term>ENABLE_NESTLOOP</term>
      <listitem>
       <para>
        Enables or disables the planner's use of nested-loop join plans.
	(It's not possible to suppress nested-loop joins entirely, but turning
	this variable OFF discourages the planner from using one if there is
	any other method available.)

	<variablelist>
	 <varlistentry>
	  <term>ON</term>
	  <listitem>
	   <para>
	    enables use of nested-loop joins (default setting).
	   </para>
	  </listitem>
	 </varlistentry>
	
600
	 <varlistentry>
601
	  <term>OFF</term>
602 603
	  <listitem>
	   <para>
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624
	    disables use of nested-loop joins.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term>ENABLE_MERGEJOIN</term>
      <listitem>
       <para>
        Enables or disables the planner's use of mergejoin plans.

	<variablelist>
	 <varlistentry>
	  <term>ON</term>
	  <listitem>
	   <para>
	    enables use of merge joins (default setting).
625 626 627
	   </para>
	  </listitem>
	 </varlistentry>
628
	
629
	 <varlistentry>
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650
	  <term>OFF</term>
	  <listitem>
	   <para>
	    disables use of merge joins.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term>ENABLE_HASHJOIN</term>
      <listitem>
       <para>
        Enables or disables the planner's use of hashjoin plans.

	<variablelist>
	 <varlistentry>
	  <term>ON</term>
651 652
	  <listitem>
	   <para>
653 654 655 656 657 658 659 660 661 662
	    enables use of hash joins (default setting).
	   </para>
	  </listitem>
	 </varlistentry>
	
	 <varlistentry>
	  <term>OFF</term>
	  <listitem>
	   <para>
	    disables use of hash joins.
663 664 665 666 667
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
668 669
      </listitem>
     </varlistentry>
670

671 672 673
     <varlistentry>
      <term>GEQO</term>
      <listitem>
674
       <para>
675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708
	Sets the threshold for using the genetic optimizer algorithm.

	<variablelist>
	 <varlistentry>
	  <term>ON</term>
	  <listitem>
	   <para>
	    enables the genetic optimizer algorithm
	    for statements with 11 or more tables.
	    (This is also the DEFAULT setting.)
	   </para>
	  </listitem>
	 </varlistentry>

	 <varlistentry>
	  <term>ON=<replaceable class="parameter">#</replaceable></term>
	  <listitem>
	   <para>
	    Takes an integer argument to enable the genetic optimizer algorithm
	    for statements with <replaceable class="parameter">#</replaceable>
	    or more tables in the query.
	   </para>
	  </listitem>
	 </varlistentry>

	 <varlistentry>
	  <term>OFF</term>
	  <listitem>
	   <para>
	    disables the genetic optimizer algorithm.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
709
       </para>
710

711
       <para>
712 713
	See the chapter on GEQO in the Programmer's Guide
	for more information about query optimization.
714 715
       </para>
       <para>
716 717 718
        If the PGGEQO environment variable is set in the frontend
	environment of a client based on libpq, libpq will automatically
	set GEQO to the value of PGGEQO during connection startup.
719 720 721 722
       </para>
      </listitem>
     </varlistentry>

723
     <varlistentry>
724
      <term>KSQO</term>
725
      <listitem>
726
       <para>
727 728 729 730 731 732 733 734 735 736
	<firstterm>Key Set Query Optimizer</firstterm> causes the query
	planner to convert queries whose WHERE clause contains many
	OR'ed AND clauses (such as "WHERE (a=1 AND b=2) OR (a=2 AND b=3) ...")
	into a UNION query.  This method can be faster than the default
	implementation, but it doesn't necessarily give exactly the same
	results, since UNION implicitly adds a SELECT DISTINCT clause to
	eliminate identical output rows.  KSQO is commonly used when
	working with products like <productname>MicroSoft
	Access</productname>, which tend to generate queries of this form.

737 738
	<variablelist>
	 <varlistentry>
739
	  <term>ON</term>
740 741
	  <listitem>
	   <para>
742 743 744 745 746 747
	    enables this optimization.
	   </para>
	  </listitem>
	 </varlistentry>
	
	 <varlistentry>
748
	  <term>OFF</term>
749 750
	  <listitem>
	   <para>
751
	    disables this optimization (default setting).
752 753 754 755 756
	   </para>
	  </listitem>
	 </varlistentry>
	 
	 <varlistentry>
757
	  <term>DEFAULT</term>
758 759
	  <listitem>
	   <para>
760
	    Equivalent to specifying <command>SET KSQO=OFF</command>.
761 762 763 764 765
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
766

767
       <para>
768 769 770
        The KSQO algorithm used to be absolutely essential for queries
	with many OR'ed AND clauses, but in Postgres 7.0 and later
	the standard planner handles these queries fairly successfully.
771 772 773
       </para>
      </listitem>
     </varlistentry>
774

775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797
     <varlistentry>
      <term>MAX_EXPR_DEPTH</term>
      <listitem>
       <para>
        Sets the maximum expression nesting depth that the parser will
	accept.  The default value is high enough for any normal query,
	but you can raise it if you need to.  (But if you raise it too high,
	you run the risk of backend crashes due to stack overflow.)

	<variablelist>
	 <varlistentry>
	  <term><replaceable class="parameter">integer</replaceable></term>
	  <listitem>
	   <para>
	    Maximum depth.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
      </listitem>
     </varlistentry>

798 799 800
    </variablelist>
   </para>
  </refsect2>
801

802 803 804 805 806
  <refsect2 id="R2-SQL-SET-2">
   <refsect2info>
    <date>1998-09-24</date>
   </refsect2info>
   <title>
807
    Outputs
808 809
   </title>
   <para>
810
    
811 812
    <variablelist>
     <varlistentry>
813 814 815
      <term><computeroutput>
SET VARIABLE
       </computeroutput></term>
816 817
      <listitem>
       <para>
818 819 820 821 822
	Message returned if successfully.
       </para>
      </listitem>
     </varlistentry>
     
823
     <varlistentry>
824 825 826
      <term><computeroutput>
WARN:  Bad value for <replaceable class="parameter">variable</replaceable> (<replaceable class="parameter">value</replaceable>)
       </computeroutput></term>
827 828 829
      <listitem>
       <para>
	If the command fails to set the specified variable.
830 831 832 833
       </para>
      </listitem>
     </varlistentry>
     
834
    </variablelist>
835
   </para>
836 837
  </refsect2>
 </refsynopsisdiv>
838
 
839 840 841 842 843
 <refsect1 id="R1-SQL-SET-1">
  <refsect1info>
   <date>1998-09-24</date>
  </refsect1info>
  <title>
844
   Description
845 846
  </title>
  <para>
847 848 849 850 851 852 853 854 855 856 857 858 859
   <command>SET</command> will modify configuration parameters for variable during
   a session.
  </para>
  <para>
   Current values can be obtained using <command>SHOW</command>, and values
   can be restored to the defaults using <command>RESET</command>.
   Parameters and values are case-insensitive. Note that the value
   field is always specified as a string, so is enclosed in
   single-quotes.
  </para>
  <para>
   <command>SET TIME ZONE</command> changes the session's
   default time zone offset.
860
   An SQL-session always begins with an initial default time zone
861 862 863 864 865
   offset.
   The <command>SET TIME ZONE</command> statement is used to change the default
   time zone offset for the current SQL session.
  </para>
  
866 867 868 869 870
  <refsect2 id="R2-SQL-SET-3">
   <refsect2info>
    <date>1998-09-24</date>
   </refsect2info>
   <title>
871
    Notes
872 873
   </title>
   <para>
874 875 876 877 878 879 880
    The <command>SET <replaceable class="parameter">variable</replaceable></command>
    statement is a <productname>Postgres</productname> language extension.
   </para>
   <para>
    Refer to <command>SHOW</command> and <command>RESET</command> to 
    display or reset the current values.
   </para>
881 882
  </refsect2>
 </refsect1>
883
 
884 885
 <refsect1 id="R1-SQL-SET-2">
  <title>
886
   Usage
887 888
  </title>
  <para>
889 890
   Set the style of date to ISO (no quotes on the argument is required):

891
   <programlisting>
892
SET DATESTYLE TO ISO;
893 894
   </programlisting>

895 896
   Enable GEQO for queries with 4 or more tables (note the use of
   single quotes to handle the equal sign inside the value argument):
897 898

   <programlisting> 
T
Tom Lane 已提交
899
SET GEQO = 'ON=4';
900 901 902 903 904
   </programlisting>

   Set GEQO to default:

   <programlisting> 
905
SET GEQO = DEFAULT;
906 907
   </programlisting>

908 909 910
   Set the timezone for Berkeley, California, using double quotes to
   preserve the uppercase
   attributes of the time zone specifier:
911

912
<programlisting> 
913
SET TIME ZONE "PST8PDT";
914
SELECT CURRENT_TIMESTAMP AS today;
915
   
916 917 918 919
         today
------------------------
 1998-03-31 07:41:21-08
</programlisting>
920

921 922
   Set the timezone for Italy (note the required single or double quotes to handle 
   the special characters):
923

924
<programlisting> 
925 926
SET TIME ZONE 'Europe/Rome';
SELECT CURRENT_TIMESTAMP AS today;
927
   
928 929 930 931
         today
------------------------
 1998-03-31 17:41:31+02
</programlisting>
932
  </para>
933
 </refsect1>
934

935 936
 <refsect1 id="R1-SQL-SET-3">
  <title>
937
   Compatibility
938
  </title>
939
  
940 941 942 943 944
  <refsect2 id="R2-SQL-SET-4">
   <refsect2info>
    <date>1998-09-24</date>
   </refsect2info>
   <title>
945
    SQL92
946 947
   </title>
   <para>
948
    There is no general
949
    <command>SET <replaceable class="parameter">variable</replaceable></command>
950 951 952
    in <acronym>SQL92</acronym> (with the exception of
    <command>SET TRANSACTION ISOLATION LEVEL</command>).

953 954 955 956
    The <acronym>SQL92</acronym> syntax for <command>SET TIME ZONE</command>
    is slightly different,
    allowing only a single integer value for time zone specification:
    
957 958 959
    <synopsis>
SET TIME ZONE { interval_value_expression | LOCAL }
    </synopsis>
960 961 962
   </para>
  </refsect2>
 </refsect1>
963
</refentry>
964 965 966

<!-- Keep this comment at the end of the file
Local variables:
967
mode:sgml
968 969 970 971 972 973 974 975 976
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
977
sgml-local-catalogs:("/usr/lib/sgml/catalog")
978 979 980
sgml-local-ecat-files:nil
End:
-->