EXERCISES
12.1 According to the BNF grammar given in the body of the chapter, which of the following are legal as “stand alone” expressions (i.e., expressions not nested inside other expressions) and which not, syntactically speaking? (A and B are table names, and you can assume the tables they denote satisfy the requirements for the operator in question in each case.)
ANATURAL JOINBAINTERSECTBSELECT * FROMANATURAL JOINBSELECT * FROMAINTERSECTBSELECT * FROM (ANATURAL JOINB) SELECT * FROM (AINTERSECTB) SELECT * FROM ( SELECT * FROMAINTERSECT SELECT * FROMB) SELECT * FROM (ANATURAL JOINB) ASCSELECT * FROM (AINTERSECTB) ASCTABLEANATURAL JOIN TABLEBTABLEAINTERSECT TABLEBSELECT * FROMAINTERSECT SELECT * FROMB( SELECT * FROMA) INTERSECT ( SELECT * FROMB) ( SELECT * FROMA) ASAAINTERSECT ( SELECT * FROMB) ASBB
What do you conclude from this exercise? Perhaps I should remind you that, relationally speaking, intersection is a special case of natural join.
12.2 Take another look at the expressions in Exercise 12.1. In which of those expressions would it be syntactically legal to replace A or B or both by “table literals” (i.e., appropriate VALUES invocations)?
12.3 Let X and Y both be of the same character string type and be subject to the same collation; let PAD SPACE apply to that collation (not recommended, of course); and let X and Y have the values ’42’ and ’42 ’, respectively (note the trailing space in the second of these). Then ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access