Structured Query Language (SQL)

Last Edited



Definition of Structured Query Language in the Network Encyclopedia.

What is Structured Query Language (SQL)?

SQL stands for Structured Query Language, a standards-based language used by relational database management programs primarily for constructing queries. Structured Query Language was originally developed by IBM for mainframe computing environments and is widely used in relational database management systems.

SQL - Structured Query Language

The standard version of SQL is defined by the American National Standards Institute (ANSI), but many vendors have made enhancements to its syntax and command functions. The latest SQL standard is called SQL-92 but is more properly known as ANSI standard SQL X3.135-1992 or International Organization for Standardization (ISO) standard ISO/IEC 9075:1992.

How It Works

SQL includes a number of statements that can be used to perform different types of relational operations on the contents of a database, including creating databases and database objects, modifying these objects, and querying databases for information. The most basic SQL statement is the SELECT statement, which you can use to retrieve rows and columns of data from database tables and format the results set. The typical format of a SELECT statement is

SELECT <columns> FROM <tables> WHERE <rows>

where a group of columns are retrieved from a table or tables in which data values are restricted to a particular row or rows. To return all the columns from a table, you can use a wildcard (but this is generally inefficient and should be avoided):

SELECT * FROM <tables>

Procedural extensions

SQL is designed for a specific purpose: to query data contained in a relational database. SQL is a set-based, declarative programming language, not an imperative programming language like C or BASIC. However, extensions to Standard SQL add procedural programming language functionality, such as control-of-flow constructs. Examples:

SourceAbbreviationFull name
ANSI/ISO StandardSQL/PSMSQL/Persistent Stored Modules
Interbase / FirebirdPSQLProcedural SQL
IBM DB2SQL PLSQL Procedural Language (implements SQL/PSM)
IBM InformixSPLStored Procedural Language
IBM NetezzaNZPLSQL(based on Postgres PL/pgSQL)
InvantivePSQLInvantive Procedural SQL (implements SQL/PSM and PL/SQL)
Mimer SQLSQL/PSMSQL/Persistent Stored Module (implements SQL/PSM)
MySQLSQL/PSMSQL/Persistent Stored Module (implements SQL/PSM)
MonetDBSQL/PSMSQL/Persistent Stored Module (implements SQL/PSM)
NuoDBSSPStarkey Stored Procedures
OraclePL/SQLProcedural Language/SQL (based on Ada programming language)
PostgreSQLPL/pgSQLProcedural Language/PostgreSQL Structured Query Language (implements SQL/PSM)
SAP R/3ABAPAdvanced Business Application Programming
SybaseWatcom-SQLSQL Anywhere Watcom-SQL Dialect
TeradataSPLStored Procedural Language

Interoperability and standardization

SQL implementations are incompatible between vendors and do not necessarily completely follow standards. In particular date and time syntax, string concatenation, NULLs, and comparison case sensitivity vary from vendor to vendor.

Particular exceptions are PostgreSQL and Mimer SQL which strive for standards compliance, though PostgreSQL does not adhere to the standard in how folding of unquoted names is done. The folding of unquoted names to lower case in PostgreSQL is incompatible with the SQL standard, which says that unquoted names should be folded to upper case. Thus, Foo should be equivalent to FOO not foo according to the standard.

See also: