The de-facto language for database applications is SQL. It evolved through several phases of standardization to the version currently known as SQL:2016. 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 MAL (MonetDB Assembly Language) statements. In this process common optimization heuristics, specific to the relational algebra are performed. There are bindings for SQL with programming languages: C (ODBC, Mapi, MonetDB/e), Java (JDBC), Python, PHP, Ruby on Rails to integrate seamlessly in the existing application developments environments.
The remainder of this manual presents a synopsis of the SQL 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. 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.
CREATE SCHEMA | COMMENT ON SCHEMA | ALTER SCHEMA | DROP SCHEMA |
SET SCHEMA |
SELECT | SELECT INTO | WITH SELECT | |
INSERT VALUES | INSERT SELECT | ||
UPDATE | MERGE | DELETE | TRUNCATE |
PREPARE | EXECUTE | DEALLOCATE | CALL |
SET | SET TIME ZONE | SET CURRENT_TIMEZONE |
COPY INTO FROM | COPY INTO FROM STDIN | COPY BINARY INTO FROM | COPY LOADER INTO FROM |
COPY INTO | COPY INTO STDOUT |
START TRANSACTION | COMMIT | ROLLBACK | |
SET TRANSACTION | SET LOCAL TRANSACTION | ||
SAVEPOINT | RELEASE SAVEPOINT | ROLLBACK TO SAVEPOINT |
EXPLAIN | PLAN | TRACE | DEBUG |
ANALYZE | SET OPTIMIZER |
CURRENT_SCHEMA | CURRENT_USER | CURRENT_DATE | CURRENT_TIME |
CURRENT_TIMESTAMP | CURRENT_TIMEZONE | LOCALTIME | LOCALTIMESTAMP |
LOCALTIMESTAMP | NEXT VALUE FOR |