Полный синтаксис SELECT
В предыдущих разделах использовались неполные или упрощенные фрагменты синтаксиса оператора SELECT
. Ниже приведен полный синтаксис.
Note
|
Там, где это возможно, в приведенном ниже синтаксисе используются синтаксические имена из стандарта SQL, которые не обязательно совпадают с синтаксическими именами в исходном коде Firebird. В некоторых случаях синтаксические представления были свернуты, поскольку представления в стандарте SQL являются подробными, и поскольку они также используются для добавления дополнительных правил или определений к элементу синтаксиса. Несмотря на то, что здесь описан полный синтаксис, некоторые представления не отображаются (например, Приведенный ниже синтаксис не включает PSQL синтаксис |
SELECT
<cursor-specification> ::= <query-expression> [<updatability-clause>] [<lock-clause>] <query-expression> ::= [<with-clause>] <query-expression-body> [<order-by-clause>] [{ <rows-clause> | [<result-offset-clause>] [<fetch-first-clause>] }] <with-clause> ::= WITH [RECURSIVE] <with-list-element> [, <with-list-element> ...] <with-list-element> ::= query-name [(<column-name-list>)] AS (<query-expression>) <column-name-list> ::= column-name [, column-name ...] <query-expression-body> ::= <query-term> | <query-expression-body> UNION [{ DISTINCT | ALL }] <query-term> <query-term> ::= <query-primary> <query-primary> ::= <query-specification> | (<query-expression-body> [<order-by-clause>] [<result-offset-clause>] [<fetch-first-clause>]) <query-specification> ::= SELECT <limit-clause> [{ ALL | DISTINCT }] <select-list> FROM <table-reference> [, <table-reference> ...] [WHERE <search-condition>] [GROUP BY <value-expression> [, <value-expression> ...]] [HAVING <search-condition>] [WINDOW <window-definition> [, <window-definition> ...]] [PLAN <plan-expression>] <limit-clause> ::= [FIRST <limit-expression>] [SKIP <limit-expression>] <limit-expression> ::= <integer-literal> | <query-parameter> | (<value-expression>) <select-list> ::= * | <select-sublist> [, <select-sublist> ...] <select-sublist> ::= table-alias.* | <value-expression> [[AS] column-alias] <table-reference> ::= <table-primary> | <joined-table> <table-primary> ::= <table-or-query-name> [[AS] correlation-name] | [LATERAL] <derived-table> [<correlation-or-recognition>] | <parenthesized-joined-table> <table-or-query-name> ::= table-name | query-name | [package-name.]procedure-name [(<procedure-args>)] <procedure-args> ::= <value-expression> [, <value-expression> ...] <correlation-or-recognition> ::= [AS] correlation-name [(<column-name-list>)] <derived-table> ::= (<query-expression>) <parenthesized-joined-table> ::= (<parenthesized-joined-table>) | (<joined-table>) <joined-table> ::= <cross-join> | <natural-join> | <qualified-join> <cross-join> <table-reference> CROSS JOIN <table-primary> <natural-join> ::= <table-reference> NATURAL [<join-type>] JOIN <table-primary> <join-type> ::= INNER | { LEFT | RIGHT | FULL } [OUTER] <qualified-join> ::= <table-reference> [<join-type>] JOIN <table-primary> { ON <search-condition> | USING (<column-name-list>) } <window-definition> ::= new-window-name AS (<window-specification-details>) <window-specification-details> ::= [existing-window-name] [<window-partition-clause>] [<order-by-clause>] [<window-frame-clause>] <window-partition-clause> ::= PARTITION BY <value-expression> [, <value-expression> ...] <order-by-clause> ::= ORDER BY <sort-specification> [, <sort-specification> ...] <sort-specification> ::= <value-expression> [<ordering-specification>] [<null-ordering>] <ordering-specification> ::= ASC | ASCENDING | DESC | DESCENDING <null-ordering> ::= NULLS FIRST | NULLS LAST <window-frame-clause> ::= { RANGE | ROWS } <window-frame-extent> <window-frame-extent> ::= <window-frame-start> | <window-frame-between> <window-frame-start> ::= UNBOUNDED PRECEDING | <value-expression> PRECEDING | CURRENT ROW <window-frame-between> ::= BETWEEN { UNBOUNDED PRECEDING | <value-expression> PRECEDING | CURRENT ROW | <value-expression> FOLLOWING } AND { <value-expression> PRECEDING | CURRENT ROW | <value-expression> FOLLOWING | UNBOUNDED FOLLOWING } <rows-clause> ::= ROWS <value-expression> [TO <value-expression>] <result-offset-clause> :: = OFFSET <offset-fetch-expression> { ROW | ROWS } <offset-fetch-expression> ::= <integer-literal> | <query-parameter> <fetch-first-clause> ::= [FETCH { FIRST | NEXT } [<offset-fetch-expression>] { ROW | ROWS } ONLY] <updatability-clause> ::= FOR UPDATE [OF <column-name-list>] <lock-clause> ::= WITH LOCK [SKIP LOCKED]