SQL
Also known as: Structured Query Language, SEQUEL
Declarative language for defining, querying and modifying data in relational databases, standardized by ANSI and ISO since the 1980s.
SQL is the standard language for working with relational databases, which store data in tables made of rows and columns. It is declarative: a query describes the result wanted, such as the names of all customers in Canada who have placed more than five orders, and the database works out how to retrieve it efficiently. SELECT statements read data, filtering rows with WHERE, combining tables with JOIN and summarizing with GROUP BY; INSERT, UPDATE and DELETE change data; and CREATE TABLE and related statements define the structure, or schema.
Donald Chamberlin and Raymond Boyce designed the language at IBM in the early 1970s, building on Edgar F. Codd's relational model, under the name SEQUEL, later shortened to SQL for trademark reasons; it is pronounced either as separate letters or as sequel. Oracle shipped one of the first commercial SQL databases in 1979. The American National Standards Institute adopted SQL as a standard in 1986 and ISO followed in 1987, with many revisions since. Major systems, including PostgreSQL, MySQL, Microsoft SQL Server and SQLite, implement the standard with their own extensions.
SQL has proved remarkably durable, outlasting many predictions of its replacement, and several NoSQL and big data systems later added SQL-like query languages. It is one of the most widely used languages in data analysis, business intelligence and software development. Its best-known security pitfall is SQL injection, in which untrusted input pasted into query text lets attackers alter the query, a risk avoided by using parameterized queries. Critics point to inconsistencies between dialects and awkward features, but its declarative design, rooted in set theory and logic, remains its core strength.
Key points
- SQL is declarative: queries describe the desired result, and the database decides how to compute it.
- Donald Chamberlin and Raymond Boyce designed it at IBM in the early 1970s under the name SEQUEL.
- ANSI standardized SQL in 1986 and ISO in 1987, though each database adds its own extensions.
- Parameterized queries prevent SQL injection, the language's best-known security risk.
Related entries
Database
Organized collection of structured data stored electronically and managed by software that lets users store, query and update it reliably.
PostgreSQL
Free and open-source object-relational database system known for reliability, standards compliance and extensibility, descended from Berkeley's POSTGRES.
SQLite
Small, self-contained, serverless SQL database engine in the public domain that is embedded in phones, browsers and many other applications.
SQL Injection
Web application vulnerability in which untrusted input is interpreted as part of a database query, letting attackers read, change or delete data.
NoSQL
Broad category of databases that store data in models other than relational tables, such as documents, key-value pairs, wide columns or graphs.
ACID
Set of four properties, atomicity, consistency, isolation and durability, that guarantee database transactions are processed reliably.
Boolean Logic
Branch of algebra in which variables take only the values true and false and are combined with operations such as AND, OR and NOT.
Featured in guides
Referenced by
Other entries that discuss or point to SQL.