Скачать в pdf «PostgreSQL»


timezone to ’value’

Table 4.7: Set options

4.13    Functions and Operators

Many functions and operators are available in PostgreSQL. Function calls can take zero, one, or more arguments and return a single value. You can list all functions and their arguments using psql’s df command. You can use psql’s dd command to display comments about any specific function or group of functions, as shown in Figure

Operators differ from functions in the following ways:

•    Operators are symbols, not names.

•    Operators usually take two arguments.

•    Arguments appear to the left and right of the operator symbol.

For example, + is an operator that takes one argument on the left and one on the right, and returns the sum of the arguments. Psql’s do command lists all PostgreSQL operators and their arguments. Figure 4.23 shows a listing of operators and examples of their use. The standard arithmetic operators—addition (+), subtraction (-), multiplication (*), division (/), modulo/remainder (%), and exponentiation О—honor the standard precedence rules. That is, exponentiation is performed first; multiplication, division, and modulo second; and addition and subtraction last. You can use parentheses to alter this precedence. Other operators are evaluated in a left-to-right manner, unless parentheses are present.

4.14    Set, Show, and Reset

The set command allows you to change various PostgreSQL parameters. The changes remain in effect for the duration of the database connection. Table 4.7 shows two common parameters that can be controlled with set.

The set DATESTYLE command controls the appearance of dates when printed in psql, as seen in Table 4.8. It controls the format (slashes, dashes, or year first) and the display of the month first (us) or day first (European). The command SET DATESTYLE TO ’SQL,US’ would most likely be selected by users in the United States, while Europeans might prefer SET DATESTYLE TO test=> df

Скачать в pdf «PostgreSQL»