set.sgml 22.0 KB
Newer Older
1
<!--
2
$Header: /cvsroot/pgsql/doc/src/sgml/ref/set.sgml,v 1.30 2000/02/19 08:14:54 thomas 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 27
SET <replaceable class="PARAMETER">variable</replaceable> { TO | = } { '<replaceable class="PARAMETER">value</replaceable>' | DEFAULT }
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 54
	New value of parameter.  <option>DEFAULT</option> can be
	used to specify resetting the parameter to its default value.
55 56 57 58 59
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
   </para>
60

61 62
   <para>
    The possible variables and allowed values are:
63
		
64 65
    <variablelist>
     <varlistentry>
66
      <term>CLIENT_ENCODING | NAMES</term>
67 68
      <listitem>
       <para>
69
	Sets the multi-byte client encoding. Parameters are:
70
	
71 72
	<variablelist>
	 <varlistentry>
73
	  <term><replaceable class="parameter">value</replaceable></term>
74 75 76 77 78 79 80 81 82 83 84 85
	  <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>
86 87
	This option is only available if MULTIBYTE support was enabled
	during the configure step of building Postgres.
88 89 90 91 92
       </para>
      </listitem>
     </varlistentry>

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

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

       <para>
168
	Date format initialization may be done by:
169 170
	<simplelist>
	 <member>
171
	  Setting the <envar>PGDATESTYLE</envar> environment variable.
172 173 174
	  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.
175 176
	 </member>
	 <member>
177
	  Running postmaster using the option <option>-o -e</option> to set
178
	  dates to the <literal>European</literal> convention.
179
	  Note that this affects only some combinations of date styles; for example
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
	  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>
203
      <term>SERVER_ENCODING</term>
204 205 206 207 208 209
      <listitem>
       <para>
	Sets the multi-byte server encoding
	
	<variablelist>
	 <varlistentry>
210
	  <term><replaceable class="parameter">value</replaceable></term>
211 212
	  <listitem>
	   <para>
213
	    Sets the multi-byte server encoding.
214 215 216 217 218
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
219

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

     <varlistentry>
228
      <term>TIMEZONE</term>
229 230 231 232 233 234 235 236
      <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:
237
				
238 239
	<variablelist>
	 <varlistentry>
240
	  <term>'PST8PDT'</term>
241 242 243 244 245 246 247
	  <listitem>
	   <para>
	    set the timezone for California
	   </para>
	  </listitem>
	 </varlistentry>
	 <varlistentry>
248
	  <term>'Portugal'</term>
249 250 251 252 253 254 255
	  <listitem>
	   <para>
	    set time zone for Portugal.
	   </para>
	  </listitem>
	 </varlistentry>
	 <varlistentry>
256
	  <term>'Europe/Rome'</term>
257 258 259 260 261 262 263
	  <listitem>
	   <para>
	    set time zone for Italy.
	   </para>
	  </listitem>
	 </varlistentry>
	 <varlistentry>
264
	  <term>DEFAULT</term>
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
	  <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>
284 285 286 287 288
       <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>
289 290
      </listitem>
     </varlistentry>
291 292

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

	   <note>
308
	   <para>
V
Vadim B. Mikheev 已提交
309 310
	    <acronym>SQL92</acronym> standard requires 
	    SERIALIZABLE to be the default isolation level.
311
	   </para>
V
Vadim B. Mikheev 已提交
312
	   </note>
313 314 315 316
	  </listitem>
	 </varlistentry>
	 
	 <varlistentry>
317
	  <term>SERIALIZABLE</term>
318 319
	  <listitem>
	   <para>
V
Vadim B. Mikheev 已提交
320 321 322 323
	    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. 
324 325 326
	   </para>
	  </listitem>
	 </varlistentry>
V
Vadim B. Mikheev 已提交
327
	 
328 329 330 331
	</variablelist>
       </para>
      </listitem>
     </varlistentry>
332 333
    </variablelist>
   </para>
334

335 336 337 338 339 340 341
   <para>
    There are also several internal or optimization
    parameters which can be specified
    by the <command>SET</command> command:
    
    <variablelist>
     <varlistentry>
342
      <term>RANDOM_PAGE_COST</term>
343 344
      <listitem>
       <para>
345 346 347
        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.
348 349 350
	
	<variablelist>
	 <varlistentry>
351
	  <term><replaceable class="parameter">float8</replaceable></term>
352 353
	  <listitem>
	   <para>
354 355
	    Set the cost of a random page access
	    to the specified floating-point value.
356 357 358
	   </para>
	  </listitem>
	 </varlistentry>
359 360 361 362 363 364 365 366 367 368 369 370 371 372
	</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>
373
	 <varlistentry>
374
	  <term><replaceable class="parameter">float8</replaceable></term>
375 376
	  <listitem>
	   <para>
377 378
	    Set the cost of per-tuple CPU processing
	    to the specified floating-point value.
379 380 381 382 383
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
384 385 386 387 388 389
      </listitem>
     </varlistentry>
    
     <varlistentry>
      <term>CPU_INDEX_TUPLE_COST</term>
      <listitem>
390
       <para>
391 392 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
        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>
453 454 455
       </para>
      </listitem>
     </varlistentry>
456

457
     <varlistentry>
458
      <term>ENABLE_SEQSCAN</term>
459 460
      <listitem>
       <para>
461 462 463 464
        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.)
465

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

489 490 491
     <varlistentry>
      <term>ENABLE_INDEXSCAN</term>
      <listitem>
492
       <para>
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513
        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>
514 515 516
       </para>
      </listitem>
     </varlistentry>
517 518

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

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

547 548 549 550 551 552 553 554 555 556
     <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>
557
	 <varlistentry>
558
	  <term>ON</term>
559 560
	  <listitem>
	   <para>
561
	    enables use of sorts (default setting).
562 563 564
	   </para>
	  </listitem>
	 </varlistentry>
565 566 567 568 569 570 571 572 573 574 575 576 577
	
	 <varlistentry>
	  <term>OFF</term>
	  <listitem>
	   <para>
	    disables use of sorts.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
      </listitem>
     </varlistentry>
578

579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597
     <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>
	
598
	 <varlistentry>
599
	  <term>OFF</term>
600 601
	  <listitem>
	   <para>
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622
	    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).
623 624 625
	   </para>
	  </listitem>
	 </varlistentry>
626
	
627
	 <varlistentry>
628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648
	  <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>
649 650
	  <listitem>
	   <para>
651 652 653 654 655 656 657 658 659 660
	    enables use of hash joins (default setting).
	   </para>
	  </listitem>
	 </varlistentry>
	
	 <varlistentry>
	  <term>OFF</term>
	  <listitem>
	   <para>
	    disables use of hash joins.
661 662 663 664 665
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
666 667
      </listitem>
     </varlistentry>
668

669 670 671
     <varlistentry>
      <term>GEQO</term>
      <listitem>
672
       <para>
673 674 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
	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>
707
       </para>
708

709
       <para>
710 711
	See the chapter on GEQO in the Programmer's Guide
	for more information about query optimization.
712 713
       </para>
       <para>
714 715 716
        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.
717 718 719 720
       </para>
      </listitem>
     </varlistentry>

721
     <varlistentry>
722
      <term>KSQO</term>
723
      <listitem>
724
       <para>
725 726 727 728 729 730 731 732 733 734
	<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.

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

765
       <para>
766 767 768
        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.
769 770 771
       </para>
      </listitem>
     </varlistentry>
772

773 774 775
    </variablelist>
   </para>
  </refsect2>
776

777 778 779 780 781
  <refsect2 id="R2-SQL-SET-2">
   <refsect2info>
    <date>1998-09-24</date>
   </refsect2info>
   <title>
782
    Outputs
783 784
   </title>
   <para>
785
    
786 787
    <variablelist>
     <varlistentry>
788 789 790
      <term><computeroutput>
SET VARIABLE
       </computeroutput></term>
791 792
      <listitem>
       <para>
793 794 795 796 797
	Message returned if successfully.
       </para>
      </listitem>
     </varlistentry>
     
798
     <varlistentry>
799 800 801
      <term><computeroutput>
WARN:  Bad value for <replaceable class="parameter">variable</replaceable> (<replaceable class="parameter">value</replaceable>)
       </computeroutput></term>
802 803 804
      <listitem>
       <para>
	If the command fails to set the specified variable.
805 806 807 808
       </para>
      </listitem>
     </varlistentry>
     
809
    </variablelist>
810
   </para>
811 812
  </refsect2>
 </refsynopsisdiv>
813
 
814 815 816 817 818
 <refsect1 id="R1-SQL-SET-1">
  <refsect1info>
   <date>1998-09-24</date>
  </refsect1info>
  <title>
819
   Description
820 821
  </title>
  <para>
822 823 824 825 826 827 828 829 830 831 832 833 834
   <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.
835
   An SQL-session always begins with an initial default time zone
836 837 838 839 840
   offset.
   The <command>SET TIME ZONE</command> statement is used to change the default
   time zone offset for the current SQL session.
  </para>
  
841 842 843 844 845
  <refsect2 id="R2-SQL-SET-3">
   <refsect2info>
    <date>1998-09-24</date>
   </refsect2info>
   <title>
846
    Notes
847 848
   </title>
   <para>
849 850 851 852 853 854 855
    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>
856 857
  </refsect2>
 </refsect1>
858
 
859 860
 <refsect1 id="R1-SQL-SET-2">
  <title>
861
   Usage
862 863
  </title>
  <para>
864 865 866
   Set the style of date to ISO:
   
   <programlisting>
867
SET DATESTYLE TO 'ISO';
868 869 870 871 872
   </programlisting>

   Enable GEQO for queries with 4 or more tables:

   <programlisting> 
873
SET GEQO ON=4;
874 875 876 877 878
   </programlisting>

   Set GEQO to default:

   <programlisting> 
879
SET GEQO = DEFAULT;
880 881 882 883 884
   </programlisting>

   Set the timezone for Berkeley, California:

   <programlisting> 
885 886
SET TIME ZONE 'PST8PDT';
SELECT CURRENT_TIMESTAMP AS today;
887 888 889 890
   
   today
   ----------------------
   1998-03-31 07:41:21-08
891 892 893 894 895
   </programlisting>

   Set the timezone for Italy:

   <programlisting> 
896 897
SET TIME ZONE 'Europe/Rome';
SELECT CURRENT_TIMESTAMP AS today;
898 899 900 901
   
   today
   ----------------------
   1998-03-31 17:41:31+02
902 903
   </programlisting>
  </para>
904
 </refsect1>
905

906 907
 <refsect1 id="R1-SQL-SET-3">
  <title>
908
   Compatibility
909
  </title>
910
  
911 912 913 914 915
  <refsect2 id="R2-SQL-SET-4">
   <refsect2info>
    <date>1998-09-24</date>
   </refsect2info>
   <title>
916
    SQL92
917 918
   </title>
   <para>
919
    There is no general
920
    <command>SET <replaceable class="parameter">variable</replaceable></command>
921 922 923
    in <acronym>SQL92</acronym> (with the exception of
    <command>SET TRANSACTION ISOLATION LEVEL</command>).

924 925 926 927
    The <acronym>SQL92</acronym> syntax for <command>SET TIME ZONE</command>
    is slightly different,
    allowing only a single integer value for time zone specification:
    
928 929 930
    <synopsis>
SET TIME ZONE { interval_value_expression | LOCAL }
    </synopsis>
931 932 933
   </para>
  </refsect2>
 </refsect1>
934
</refentry>
935 936 937 938 939 940 941 942 943 944 945 946 947

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
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
948
sgml-local-catalogs:"/usr/lib/sgml/catalog"
949 950 951
sgml-local-ecat-files:nil
End:
-->