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

next up previous contents index
Next: SET, SHOW, and RESET Up: Customizing Queries Previous: Distinct Rows

Functions and Operators

 There are a large number of functions and operators available in POSTGRESQL. Function calls 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 [*].

  
Figure: Function examples
\begin{figure}\begin{list}{}{
\setlength{\rightmargin}{\leftmargin}
\raggedrigh...
...{}-{}-{}-{}-{}-{}-{}-
\par ~1.4142135624
\par (1~row)\end{list}\par
\end{figure}

Operators differ from functions because they are accessed using symbols, they always take two arguments, and the two arguments appear to the left and right of the operator symbol. For examples, + is an operator that takes one argument on the left and one on the right, and returns their sum. Psql's \do command lists all POSTGRESQL operators and their arguments. Figure [*] shows operator listings and operator use.

  
Figure: Operator examples
\begin{figure}\begin{list}{}{
\setlength{\rightmargin}{\leftmargin}
\raggedrigh...
...-{}-{}-{}-{}-{}-{}-{}-{}-
\par ~~~~~~~83
\par (1~row)\end{list}\par
\end{figure}

The standard arithmetic operators: addition (+), subtraction (-), multiplication (*), division (/), modulo/remainder (%), and exponentiation (^) honor the standard precedence rules with exponentiation done first, multiplication, division, and modulo done second, and addition and subtraction done last. Parentheses can be used to alter this precedence. Other operators are evaluated left-to-right, unless parentheses are present.


next up previous contents index
Next: SET, SHOW, and RESET Up: Customizing Queries Previous: Distinct Rows
Bruce Momjian
1999-11-21