Mercurial > urweb
comparison doc/manual.tex @ 550:11e150300ba0
DML
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 07 Dec 2008 12:10:51 -0500 |
parents | 39282473d38f |
children | 8fb99fec35f6 |
comparison
equal
deleted
inserted
replaced
549:39282473d38f | 550:11e150300ba0 |
---|---|
1252 | 1252 |
1253 \subsection{SQL} | 1253 \subsection{SQL} |
1254 | 1254 |
1255 \subsubsection{Queries} | 1255 \subsubsection{Queries} |
1256 | 1256 |
1257 Queries $Q$ are added to the rules for expressions $e$. | |
1258 | |
1257 $$\begin{array}{rrcll} | 1259 $$\begin{array}{rrcll} |
1258 \textrm{Queries} & Q &::=& (q \; [\mt{ORDER} \; \mt{BY} \; (E \; [D],)^+] \; [\mt{LIMIT} \; N] \; [\mt{OFFSET} \; N]) \\ | 1260 \textrm{Queries} & Q &::=& (q \; [\mt{ORDER} \; \mt{BY} \; (E \; [o],)^+] \; [\mt{LIMIT} \; N] \; [\mt{OFFSET} \; N]) \\ |
1259 \textrm{Pre-queries} & q &::=& \mt{SELECT} \; P \; \mt{FROM} \; T,^+ \; [\mt{WHERE} \; E] \; [\mt{GROUP} \; \mt{BY} \; p,^+] \; [\mt{HAVING} \; E] \\ | 1261 \textrm{Pre-queries} & q &::=& \mt{SELECT} \; P \; \mt{FROM} \; T,^+ \; [\mt{WHERE} \; E] \; [\mt{GROUP} \; \mt{BY} \; p,^+] \; [\mt{HAVING} \; E] \\ |
1260 &&& \mid q \; R \; q \\ | 1262 &&& \mid q \; R \; q \\ |
1261 \textrm{Relational operators} & R &::=& \mt{UNION} \mid \mt{INTERSECT} \mid \mt{EXCEPT} | 1263 \textrm{Relational operators} & R &::=& \mt{UNION} \mid \mt{INTERSECT} \mid \mt{EXCEPT} |
1262 \end{array}$$ | 1264 \end{array}$$ |
1263 | 1265 |
1290 &&& (E) & \textrm{explicit precedence} \\ | 1292 &&& (E) & \textrm{explicit precedence} \\ |
1291 \textrm{Nullary operators} & n &::=& \mt{CURRENT\_TIMESTAMP} \\ | 1293 \textrm{Nullary operators} & n &::=& \mt{CURRENT\_TIMESTAMP} \\ |
1292 \textrm{Unary operators} & u &::=& \mt{NOT} \\ | 1294 \textrm{Unary operators} & u &::=& \mt{NOT} \\ |
1293 \textrm{Binary operators} & b &::=& \mt{AND} \mid \mt{OR} \mid \neq \mid < \mid \leq \mid > \mid \geq \\ | 1295 \textrm{Binary operators} & b &::=& \mt{AND} \mid \mt{OR} \mid \neq \mid < \mid \leq \mid > \mid \geq \\ |
1294 \textrm{Aggregate functions} & a &::=& \mt{AVG} \mid \mt{SUM} \mid \mt{MIN} \mid \mt{MAX} \\ | 1296 \textrm{Aggregate functions} & a &::=& \mt{AVG} \mid \mt{SUM} \mid \mt{MIN} \mid \mt{MAX} \\ |
1295 \textrm{Directions} & D &::=& \mt{ASC} \mid \mt{DESC} \\ | 1297 \textrm{Directions} & o &::=& \mt{ASC} \mid \mt{DESC} \\ |
1296 \textrm{SQL integer} & N &::=& n \mid \{e\} \\ | 1298 \textrm{SQL integer} & N &::=& n \mid \{e\} \\ |
1297 \end{array}$$ | 1299 \end{array}$$ |
1298 | 1300 |
1299 Additionally, an SQL expression may be inserted into normal Ur code with the syntax $(\mt{SQL} \; E)$ or $(\mt{WHERE} \; E)$. | 1301 Additionally, an SQL expression may be inserted into normal Ur code with the syntax $(\mt{SQL} \; E)$ or $(\mt{WHERE} \; E)$. |
1300 | 1302 |
1303 \subsubsection{DML} | |
1304 | |
1305 DML commands $D$ are added to the rules for expressions $e$. | |
1306 | |
1307 $$\begin{array}{rrcll} | |
1308 \textrm{Commands} & D &::=& (\mt{INSERT} \; \mt{INTO} \; T^E \; (f,^+) \; \mt{VALUES} \; (E,^+)) \\ | |
1309 &&& (\mt{UPDATE} \; T^E \; \mt{SET} \; (f = E,)^+ \; \mt{WHERE} \; E) \\ | |
1310 &&& (\mt{DELETE} \; \mt{FROM} \; T^E \; \mt{WHERE} \; E) \\ | |
1311 \textrm{Table expressions} & T^E &::=& x \mid \{\{e\}\} | |
1312 \end{array}$$ | |
1313 | |
1314 Inside $\mt{UPDATE}$ and $\mt{DELETE}$ commands, lone variables $X$ are interpreted as references to columns of the implicit table $\mt{T}$, rather than to named expressions. | |
1301 | 1315 |
1302 \end{document} | 1316 \end{document} |