Online Documentation Server
 ПОИСК
ods.com.ua Web
 КАТЕГОРИИ
Home
Programming
Net technology
Unixes
Security
RFC, HOWTO
Web technology
Data bases
Other docs

 


 ПОДПИСКА

 О КОПИРАЙТАХ
Вся предоставленная на этом сервере информация собрана нами из разных источников. Если Вам кажется, что публикация каких-то документов нарушает чьи-либо авторские права, сообщите нам об этом.




Operators

Chapter 4. Operators

Describes the built-in operators available in Postgres.

Postgres provides a large number of built-in operators on system types. These operators are declared in the system catalog pg_operator. Every entry in pg_operator includes the name of the procedure that implements the operator and the class OIDs of the input and output types.

To view all variations of the "||" string concatenation operator, try

    SELECT oprleft, oprright, oprresult, oprcode
    FROM pg_operator WHERE oprname = '||';

oprleft|oprright|oprresult|oprcode
-------+--------+---------+-------
     25|      25|       25|textcat
   1042|    1042|     1042|textcat
   1043|    1043|     1043|textcat
(3 rows)
   

Users may invoke operators using the operator name, as in:

select * from emp where salary < 40000;
   
Alternatively, users may call the functions that implement the operators directly. In this case, the query above would be expressed as:
select * from emp where int4lt(salary, 40000);
   

psql has a command (\dd) to show these operators.

Lexical Precedence

Operators have a precedence which is currently hardcoded into the parser. Most operators have the same precedence and are left-associative. This may lead to non-intuitive behavior; for example the boolean operators "<" and ">" have a different precedence than the boolean operators "<=" and ">=".

Table 4-1. Operator Ordering (decreasing precedence)

ElementPrecedenceDescription
UNIONleftSQL select construct
:: Postgres typecasting
[ ]leftarray delimiters
.lefttable/column delimiter
-rightunary minus
:rightexponentiation
|leftstart of interval
* / %leftmultiplication, division, modulo
+ -leftaddition, subtraction
IS test for TRUE, FALSE, NULL
ISNULL test for NULL
NOTNULL test for NOT NULL
(all other operators) native and user-defined
IN set membership
BETWEEN containment
OVERLAPS time interval overlap
LIKE string pattern matching
< > inequality
=rightequality
NOTrightlogical negation
ANDleftlogical intersection
ORleftlogical union



With any suggestions or questions please feel free to contact us