SQL:1999 explained

SQL:1999 (also called SQL 3) was the fourth revision of the SQL database query language. It introduced many new features, many of which required clarifications in the subsequent . In the meanwhile SQL:1999 is deprecated.

Summary

The ISO standard documents were published between 1999 and 2002 in several installments, the first one consisting of multiple parts. Unlike previous editions, the standard's name used a colon instead of a hyphen for consistency with the names of other ISO standards. The first installment of SQL:1999 had five parts:

Three more parts, also considered part of SQL:1999 were published subsequently:

New features

Data types

Boolean data types

The SQL:1999 standard calls for a Boolean type,[1] but many commercial SQL servers (Oracle Database, IBM Db2) do not support it as a column type, variable type or allow it in the results set. Microsoft SQL Server is one of the few database systems that properly supports BOOLEAN values using its "BIT" data type. Every 1–8 bit fields occupies one full byte of space on disk. MySQL interprets "BOOLEAN" as a synonym for TINYINT (8-bit signed integer).[2] PostgreSQL provides a standard conforming Boolean type.[3]

Distinct user-defined types of power

Sometimes called just distinct types, these were introduced as an optional feature (S011) to allow existing atomic types to be extended with a distinctive meaning to create a new type and thereby enabling the type checking mechanism to detect some logical errors, e.g. accidentally adding an age to a salary. For example:

create type age as integer FINAL;create type salary as integer FINAL;

creates two different and incompatible types. The SQL distinct types use name equivalence not structural equivalence like typedefs in C. It's still possible to perform compatible operations on (columns or data) of distinct types by using an explicit type CAST.

Few SQL systems support these. IBM Db2 is one those supporting them.[4] Oracle database did not support them as of 2012, recommending instead to emulate them by a one-place structured type.[5]

Structured user-defined types

See main article: structured type. These are the backbone of the object–relational database extension in SQL:1999. They are analogous to classes in objected-oriented programming languages. SQL:1999 allows only single inheritance.

Common table expressions and recursive queries

SQL:1999 added a WITH [RECURSIVE] construct allowing recursive queries, like transitive closure, to be specified in the query language itself; see common table expressions.

Some OLAP capabilities

GROUP BY was extended with ROLLUP, CUBE, and GROUPING SETS.

Role-based access control

Full support for RBAC via CREATE ROLE.

Keywords

SQL:1999 introduced the UNNEST keyword.[6]

Further reading

Notes and References

  1. http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=26197 ISO/IEC 9075-2:1999
  2. Web site: MySQL :: MySQL 5.0 Reference Manual :: 11.4 Using Data Types from Other Database Engines . Dev.mysql.com . 2010-01-09 . 2014-01-30 . 2014-02-07 . https://web.archive.org/web/20140207011906/http://dev.mysql.com/doc/refman/5.0/en/other-vendor-data-types.html . live .
  3. Web site: PostgreSQL documentation about Boolean Type . 2023-12-06 . 2018-03-09 . https://web.archive.org/web/20180309053449/https://www.postgresql.org/docs/current/static/datatype-boolean.html . live .
  4. Web site: IBM Information Management Software for z/OS Solutions Information Center . Publib.boulder.ibm.com . 2014-01-30.
  5. Web site: Oracle Compliance To Core SQL:2003 . Docs.oracle.com . 2014-01-30 . 2013-12-02 . https://web.archive.org/web/20131202042209/http://docs.oracle.com/cd/B19306_01/server.102/b14200/ap_standard_sql003.htm . live .
  6. Book: Jones. Arie. Stephens. Ryan K.. Plew. Ronald R.. Garrett. Robert F.. Kriegel. Alex. Appendix B ANSI and Vendor Keywords. SQL Functions Programmer's Reference. John Wiley & Sons. 2005. 680. 9780764598074. 2016-05-16.