next up previous contents
Next: DML Up: SQL Previous: Table Declarations   Contents

Queries

Queries $ Q$ are added to the rules for expressions $ e$ .

\begin{displaymath}\begin{array}{rrcll}
\textrm{Queries} & Q &::=& (q \; [\math...
...OM} [()] \mid \hat{E} \; [o] \mid \hat{E} \; [o], O
\end{array}\end{displaymath}

\begin{displaymath}\begin{array}{rrcll}
\textrm{Projections} & P &::=& \ast & \...
...sf{RANK}() \\
&&& \mathsf{COUNT}(*) \\
&&& a(E)
\end{array}\end{displaymath}

Additionally, an SQL expression may be inserted into normal Ur code with the syntax $ (\mathsf{SQL} \; E)$ or $ (\mathsf{WHERE} \; E)$ . Similar shorthands exist for other nonterminals, with the prefix $ \mathsf{FROM}$ for $ \mathsf{FROM}$ items and $ \mathsf{SELECT1}$ for pre-queries.

Unnamed expression columns in $ \mathsf{SELECT}$ clauses are assigned consecutive natural numbers, starting with 1. Any expression in a $ p$ position that is enclosed in parentheses is treated as an expression column, rather than a column pulled directly out of a table, even if it is only a field projection. (This distinction affects the record type used to describe query results.)



2014-07-14