Skip to main content

SQL Reference Manual

The de facto language for database applications is SQL. It evolved through several phases of standardization to the version currently known as SQL-2008. The SQL standard provides an ideal language framework, in terms of standardization committee viewpoints. It is, however, hardly met by any of the existing (commercial) implementations. This is largely due to software legacy, backward compatibility requirements from their client base, and introduction of new features. See for instance the wikipedia on-line article on SQL standards and an overview of  SQL features of main-stream systems.

In 2002 the first version of the SQL front end for MonetDB emerged. This late development made it possible to immediately start from the SQL'99 definition. As soon as the SQL'03 specifications became available, its content was taken as the frame of reference. The SQL development strategy is driven by immediate needs of the user base, so that less-frequently used features end up low on the development stack. Features beyond the standard are marked as non-standard SQL in their description.

The architecture is based on a compiler, which translates SQL statements into the MonetDB Assembly Language (MAL). In this process common optimization heuristics, specific to the relational algebra are performed. There are bindings for SQL with e.g. JDBC, PHP, Ruby on Rails, Python and C, to integrate seamlessly in the existing developments environments.

The remainder of this manual presents a synopsis of the language features. It provides a quick intro on the scope of the current implementation. Proficiency in elementary use of SQL is assumed. If you are new to this world then pick up any of the introduction books and study it carefully, e.g. J. Melton and A.R. Simon, SQL:1999 Understanding Relational Language Components, ISBN 1558604561.

The language features recognized are presented in simplified BNF notation. All reserved words are depicted in capitals. Language (non) terminals are depicted in lower case italics. Optional constructs are enclosed by squary brackets  ('[',']') with alternative  choices separated by a bar ('|'), at most one can be choosen. A set of options is enclosed by curly braces '{','}' and one must be choosen. Repetition of language structures is depicted by list structures, e.g. A ',' ...  denotes a sequence of at least one A separated by commas.

Identifiers are optional qualified with a semantic tag, e.g. authid means a name for an authorised user.