Полезная информация

next up previous contents index
Next: SQL Aggregates Up: Customizing Queries Previous: Functions and Operators

SET, SHOW, and RESET

The SET command allows the changing of various POSTGRESQL parameters. The changes remain in affect for the duration of the database connection. Table [*] shows various parameters that can be controlled with SET.

 
Table: SET options
Function SET option
Datestyle DATESTYLE TO 'ISO'|'SQL'|'POSTGRES'|'EUROPEAN'|'US'|'NONEUROPEAN'
Timezone TIMEZONE TO 'value'
Client encodings CLIENT_ENCODING|NAMES TO encoding
Server encodings SERVER_ENCODING TO encoding
Transaction isolation level TRANSACTION ISOLATION LEVEL 'SERIALIZABLE'|'READ COMMITTED'
Optimizer heap cost COST_HEAP TO #
Optimizer index cost COST_INDEX TO #
Genetic Query Optimizer (GEQO) GEQO TO 'ON[=#]'|'OFF'
Key Set Query Optimizer (KSQO) KSQO TO 'ON'|'OFF'
Enable trace flags PG_OPTIONS TO 'value'


DATESTYLE controls the appearance of dates when printed in psql as seen in table [*].
 
Table: DATESTYLE output
  Output for
Style Optional Ordering February 1, 1983
POSTGRES us or NONEUROPEAN 02/01/1983
POSTGRES EUROPEAN 01/02/1983
SQL US or NONEUROPEAN 02-01-1983
SQL EUROPEAN 01-02-1983
ISO 1983-02-01


It allows control of the format (slashes, dashes, or year first), and the convention of having the month first (US) or day first (European). The command SET DATESTYLE TO 'SQL,US' would most likely be used by users in the USA, while Europeans may prefer SET DATESTYLE TO 'POSTGRES,EUROPEAN'. The ISO DATESTYLE is not affected by any of the other options.

TIMEZONE defaults to the timezone of the server or the PGTZ environment variable. The psql client may be in a different timezone, and SET TIMEZONE allows this to be changed inside psql. TRANSACTION ISOLATION will be covered in section [*]. The other options are for developer use during debugging sessions.

The SHOW command is used to display current database session parameters. RESET allows session parameters to be reset to their default values. Figure [*] shows an example of this.6.6

  
Figure: SHOW and RESET examples
\begin{figure}\begin{list}{}{
\setlength{\rightmargin}{\leftmargin}
\raggedrigh...
...~with~US~(NonEuropean)~conventions
\par SHOW~VARIABLE\end{list}\par
\end{figure}


next up previous contents index
Next: SQL Aggregates Up: Customizing Queries Previous: Functions and Operators
Bruce Momjian
1999-11-21