PostgreSQL

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

distributors: did | name


——+————-


108 | Westward


111    | Walt Disney


112    | Warner Bros.



actors: id | name —-+—————-


1    | Woody Allen


2    | Warren Beatty


3    | Walter Matthau


SELECT distributors.name


FROM distributors


WHERE distributors.name LIKE ‘W%’


union


SELECT actors.name FROM actors


WHERE actors.name LIKE ‘W%’ name


Walt Disney Walter Matthau Warner Bros.


Warren Beatty Westward Woody Allen


Compatibility


Extensions


Postgres allows one to omit the FROM clause from a query. This feature was retained from the original PostQuel query language:


SELECT distributors.*


WHERE name = ‘Westwood’; did | name


——+———-


108 | Westward


SQL92


select Clause


In the SQL92 standard, the optional keyword «AS» is just noise and can be omitted without affecting the meaning. The Postgres parser requires this keyword when renaming columns because the type extensibility features lead to parsing ambiguities in this context.


The DISTINCT ON phrase is not part of SQL92. Nor are LIMIT and OFFSET.


In SQL92, an ORDER BY clause may only use result column names or numbers, while a GROUP BY clause may only use input column names. Postgres extends each of these clauses to allow the other choice as well (but it uses the standard’s interpretation if there is ambiguity). Postgres also allows both clauses to specify arbitrary expressions. Note that names appearing in an expression will always be taken as input-column names, not as result-column names.

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