The SQL reference article from the English Wikipedia on 24-Jul-2004
(provided by Fixed Reference: snapshots of Wikipedia from wikipedia.org)

SQL

For thoughtful child sponsors
Structured Query Language (SQL) is the most popular computer language used with databases.

Technically, SQL is a declarative programming language for use in "quasi-relational databases". Theorists note that many of the original SQL features were inspired by, but in violation of, tuple calculus. Recent extensions to SQL achieved relational completeness, but have worsened the violations.

Table of contents
1 Origins
2 SQL keywords
3 Database systems using SQL
4 External links

Origins

SQL was originally created by IBM, but many vendors developed dialects of it. It was adopted as a standard by the American National Standards Institute (ANSI) in 1986 and ISO in 1987. In their SQL standard, the ANSI declared that the official pronunciation for SQL is "es queue el". However, many database professionals have taken to the "slang" pronunciation sequel, that reflects the language's original name, Sequel, before trademark conflicts caused IBM to propagate the current moniker.

The SQL standard has gone through a number of revisions:
Year Name Alias Comments
1986 SQL-86 SQL-87 First published by ANSI. Ratified by ISO in 1987.
1989 SQL-89 Minor revision.
1992 SQL-92 SQL2 Major revision.
1999 SQL:1999 SQL3 Added regular expression matching, recursive queries, triggers, non-scalar types, some object-oriented features. (The last two are somewhat controversial and not yet widely supported.)
2003 SQL:2003 Introduced XML-related features, standardized sequences and columns with auto-generated values (including identity-columns). (See Eisenberg et al.: SQL:2003 Has Been Published.)

The SQL standard is not freely available. SQL:2003 may be bought from ISO or ANSI. A late draft is available as a zip-file from Whitemarsh Information Systems Corporation. The zip-file contains a number of PDF files, most importantly 5WD-02-Foundation-2003-09.pdf which defines part 2 of the standard: SQL/Foundation.

SQL, although defined by both ANSI and ISO, has many variations and extensions, most of which are of a proprietary nature, such as Oracle Corporation's PL/SQL or Sybase and Microsoft's Transact-SQL. It is also not uncommon for commercial implementations to omit support for basic features of the standard, such as the DATE or TIME data types, preferring some variant of their own. As a result in contrast to ANSI C or ANSI Fortran which can usually be ported from platform to platform without major structural changes, SQL code can rarely be ported between database systems without major modifications. Most people in the field believe that this lack of compatibility is intentional in order to ensure vendor lock-in for proprietary database systems.

As the name implies, SQL is designed for a specific, limited purpose -- querying data contained in a relational database. As such, it is a set-based programming language rather than a procedural language such as C or BASIC, which are designed to solve a much broader set of problems. Language extensions such as PL/SQL are designed to address this by adding procedural elements to SQL while maintaining SQL's advantages. Another approach is to allow procedural language code to be embedded in and interact with the database. For example, Oracle and others include Java in the database, while PostgreSQL allows functions to be written in Perl, Tcl, or C, among other languages.

One joke about SQL is that "SQL is neither Structured, nor a Language." This is (in part) founded on the notion that SQL isn't a Turing complete language.

SQL keywords

SQL keywords fall into a number of groups.

First there are the standard Data Manipulation Language (DML) elements. DML is the subset of the language used to query a database, add, update and delete data.

Three other keywords could be said to fall into DML:

COMMIT and ROLLBACK interact with areas such as transaction control and locking. Strictly, both terminate any open transaction and release any locks held on data. In the absence of a BEGIN WORK or similar statement, the semantics of SQL are implementation-dependent.

The second group of keywords is the Data Definition Language (DDL). DDL allows the user to define new tables and associated elements. Most commercial SQL databases have proprietary extensions in their DDL, which allow control over proprietary and nonstandard, but usually operationally vital, elements of the specific system.

The most basic items of DDL are the CREATE and DROP commands.

Some database systems also have an ALTER command, which permits the user to modify an existing object in various ways - for example, adding a column to an existing table.

The third group of SQL keywords is the Data Control Language (DCL). DCL handles the authorisation aspects of data and permits the user to control who has access to see or manipulate data within the database.

Its two main keywords are

Database systems using SQL

External links