Loading learning content...
When you write a SQL query, you might assume that the same query will work identically across Oracle, PostgreSQL, SQL Server, and MySQL. In theory, that should be true—SQL is a standardized language. In practice, the reality is far more nuanced.
Understanding SQL standards is essential for writing portable code, evaluating database products, and navigating the complex landscape of vendor-specific extensions. Standards define not just syntax, but semantics—what SQL should do, not just how to write it.
This page explores the SQL standardization process, the major standard versions, conformance levels, and the practical implications for your work.
By the end of this page, you will understand how SQL standards are developed and ratified, the major milestones in SQL standardization history, what conformance levels mean, and how to navigate the gap between standard SQL and vendor-specific dialects.
SQL standardization is a formal process involving recognized international standards organizations. Understanding who creates these standards helps you appreciate their authority and limitations.
ANSI (American National Standards Institute):
ANSI is the United States' representative body to ISO and IEC. It oversees the development of voluntary consensus standards for products, services, processes, and systems in the US. ANSI's Database Committee (NCITS H2, formerly X3H2) has been responsible for SQL standards development since the 1980s.
ISO (International Organization for Standardization):
ISO is an independent, non-governmental international organization with 167 member countries. ISO/IEC JTC 1/SC 32 (Data Management and Interchange) maintains the international SQL standard. ANSI and ISO coordinate to produce identical SQL standards—what's called a 'dual-logo' standard.
A major SQL standard revision typically takes 3-5 years from initial proposal to publication. This deliberate pace ensures thorough review but means standards often lag behind vendor implementations. Vendors frequently implement features before they're standardized, creating tension between innovation and portability.
The ISO/IEC 9075 Document Structure:
The SQL standard is not a single document but a multi-part specification covering different aspects of the language:
| Part | Title | Description |
|---|---|---|
| Part 1 | SQL/Framework | Overview and common definitions |
| Part 2 | SQL/Foundation | Core SQL: data types, schemas, queries, DML |
| Part 3 | SQL/CLI | Call-Level Interface (programmatic access) |
| Part 4 | SQL/PSM | Persistent Stored Modules (procedures, functions) |
| Part 9 | SQL/MED | Management of External Data (foreign tables) |
| Part 10 | SQL/OLB | Object Language Bindings (embedded SQL) |
| Part 11 | SQL/Schemata | Information schema and definition schema |
| Part 13 | SQL/JRT | SQL Routines using Java (deprecated) |
| Part 14 | SQL/XML | XML-related specifications |
| Part 15 | SQL/MDA | Multi-dimensional arrays |
| Part 16 | SQL/PGQ | Property Graph Queries |
For most developers, Part 2 (SQL/Foundation) is the heart of the standard—it defines the SELECT, INSERT, UPDATE, DELETE statements, data types, joins, subqueries, and virtually everything you use daily. The other parts address specialized capabilities or legacy interfaces.
The SQL standard has evolved dramatically since 1986, each version adding capabilities while maintaining backward compatibility. Understanding this evolution helps you recognize which features are widely supported versus which are cutting-edge.
SQL-86 (SQL1): The Foundation
The first standard was relatively minimal, formalizing what System R and early commercial databases already implemented:
SELECT...FROM...WHERE queriesINSERT, UPDATE, DELETE statementsCREATE TABLE, CREATE VIEW)SQL-89: Minor Enhancements
A minor revision that clarified ambiguities and added:
CASCADE)SQL-92 (also called SQL2) is the most significant revision in SQL history. It expanded the standard from ~100 pages to over 600 pages and defined the SQL syntax that developers still use daily. When people discuss 'standard SQL,' they often mean SQL-92 core features.
SQL-92: The Watershed Standard
SQL-92 introduced transformative features that defined modern SQL:
INNER JOIN, LEFT OUTER JOIN, RIGHT OUTER JOIN, FULL OUTER JOIN with ON clausesSUBSTRING, TRIM, UPPER, LOWER, concatenation operatorDATE, TIME, TIMESTAMP, INTERVAL123456789101112131415161718192021222324252627
-- Pre-SQL-92: Implicit join in WHERE clauseSELECT e.name, d.department_nameFROM employees e, departments dWHERE e.department_id = d.id AND e.salary > 50000; -- SQL-92: Explicit JOIN syntaxSELECT e.name, d.department_nameFROM employees eINNER JOIN departments d ON e.department_id = d.idWHERE e.salary > 50000; -- SQL-92: Outer joins with standard syntaxSELECT e.name, d.department_nameFROM employees eLEFT OUTER JOIN departments d ON e.department_id = d.id; -- SQL-92: CASE expressions for conditional logicSELECT name, salary, CASE WHEN salary >= 100000 THEN 'Senior' WHEN salary >= 50000 THEN 'Mid-Level' ELSE 'Junior' END AS levelFROM employees;SQL:1999 (SQL3): Object-Relational Extensions
SQL:1999 brought object-oriented concepts into the relational world:
WITH RECURSIVE for hierarchical dataSIMILAR TO and LIKE pattern matchingGROUPING SETS, CUBE, ROLLUP for analytics123456789101112131415161718192021
-- Find all employees in a management hierarchy-- Recursive CTE introduced in SQL:1999 WITH RECURSIVE management_chain AS ( -- Base case: top-level manager SELECT id, name, manager_id, 0 AS level FROM employees WHERE manager_id IS NULL UNION ALL -- Recursive case: employees reporting to current level SELECT e.id, e.name, e.manager_id, mc.level + 1 FROM employees e INNER JOIN management_chain mc ON e.manager_id = mc.id)SELECT * FROM management_chainORDER BY level, name; -- This was impossible in standard SQL before SQL:1999-- Each vendor had proprietary solutions (CONNECT BY in Oracle, etc.)The 21st century brought continued SQL evolution, addressing new data paradigms and analytical needs.
SQL:2003 — The Analytic Revolution
SQL:2003 introduced capabilities that transformed SQL from a simple query language into a powerful analytical tool:
ROW_NUMBER(), RANK(), DENSE_RANK(), NTILE(), LAG(), LEAD() with OVER() clauseCREATE SEQUENCE for auto-increment values12345678910111213141516171819202122232425262728293031
-- Window functions revolutionized analytical SQL-- Analyze data within partitions without self-joins -- Rank employees within each department by salarySELECT name, department, salary, RANK() OVER ( PARTITION BY department ORDER BY salary DESC ) AS salary_rank_in_dept, salary - LAG(salary, 1) OVER ( PARTITION BY department ORDER BY salary DESC ) AS gap_to_previousFROM employees; -- Calculate running totals and moving averagesSELECT order_date, amount, SUM(amount) OVER ( ORDER BY order_date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) AS running_total, AVG(amount) OVER ( ORDER BY order_date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW ) AS weekly_moving_avgFROM orders;SQL:2011 — Temporal Data
SQL:2011 addressed a long-standing challenge: managing time-varying data.
FOR SYSTEM_TIME AS OF, FOR SYSTEM_TIME BETWEEN1234567891011121314151617181920212223242526
-- System-versioned temporal table-- Database automatically tracks all historical states CREATE TABLE employees ( id INTEGER PRIMARY KEY, name VARCHAR(100), salary DECIMAL(10,2), -- System time tracking sys_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START, sys_end TIMESTAMP(6) GENERATED ALWAYS AS ROW END, PERIOD FOR SYSTEM_TIME (sys_start, sys_end)) WITH SYSTEM VERSIONING; -- Query current data (default)SELECT * FROM employees; -- Query data as it was on a specific dateSELECT * FROM employeesFOR SYSTEM_TIME AS OF TIMESTAMP '2024-01-01 00:00:00'; -- Query complete history of changesSELECT * FROM employeesFOR SYSTEM_TIME BETWEEN TIMESTAMP '2023-01-01 00:00:00' AND TIMESTAMP '2024-01-01 00:00:00';SQL:2016 — JSON and Pattern Matching
SQL:2016 acknowledged the rise of JSON in web applications:
JSON_VALUE, JSON_QUERY, JSON_TABLE for extraction and transformationMATCH_RECOGNIZE for complex event processingSQL:2023 — Property Graphs
The latest major standard brings graph database capabilities to SQL:
Not every database implements every SQL standard feature. To address this reality, the SQL standard defines conformance levels—graduated tiers of feature support.
The Core Conformance Concept:
Starting with SQL:1999, the standard defines:
A database claiming 'SQL conformance' must support Core SQL. Beyond that, vendors choose which optional features to implement.
| Level | Features | Target Audience |
|---|---|---|
| Entry | Basic SELECT, INSERT, UPDATE, DELETE; simple data types; basic constraints | Minimal compliance; legacy systems |
| Intermediate | Entry + domains, assertions, more data types, enhanced joins | Production systems requiring robust features |
| Full | Intermediate + complete standard implementation | Maximum portability; rarely achieved |
No major commercial database fully implements the SQL standard. Even PostgreSQL, known for standards compliance, has gaps and deviations. The standard is a reference point, not a rigid requirement enforced by any authority.
Feature Packages:
Modern SQL standards organize optional features into logical packages. Here are examples of feature packages from SQL:2023:
| Package | Features Included | Database Support |
|---|---|---|
| Core SQL | Basic queries, joins, constraints, transactions | All major databases |
| Enhanced datetime facilities | INTERVAL arithmetic, timezone support, precision control | Most major databases |
| Active database (triggers) | BEFORE/AFTER triggers, ROW/STATEMENT level | Oracle, PostgreSQL, SQL Server |
| OLAP facilities | CUBE, ROLLUP, GROUPING SETS, window functions | Most major databases |
| Temporal tables | System-versioned tables, temporal queries | SQL Server, MariaDB, DB2 (limited elsewhere) |
| JSON support | JSON data type, path queries, construction | PostgreSQL, MySQL, SQL Server, Oracle |
Database documentation typically lists SQL standard conformance details. PostgreSQL, for example, maintains an appendix mapping each SQL feature to its implementation status. When writing portable SQL, focus on Core SQL features and widely-implemented optional features.
Despite standardization, each major database has developed its own SQL dialect—variations in syntax, additional proprietary features, and different interpretations of standard features. Understanding these dialects is essential for real-world database work.
Common Dialect Differences:
Let's examine how common operations differ across major databases:
| Operation | Standard SQL | Oracle | SQL Server | MySQL | PostgreSQL |
|---|---|---|---|---|---|
| Limit rows | FETCH FIRST n ROWS | FETCH FIRST n ROWS or ROWNUM | TOP n or OFFSET/FETCH | LIMIT n | LIMIT n or FETCH FIRST |
| String concat | || | || | + | CONCAT() | || |
| Current date | CURRENT_DATE | SYSDATE | GETDATE() | CURDATE() | CURRENT_DATE |
| Auto-increment | GENERATED AS IDENTITY | GENERATED AS IDENTITY | IDENTITY(1,1) | AUTO_INCREMENT | SERIAL or GENERATED |
| Boolean type | BOOLEAN | Not native (NUMBER) | BIT | BOOLEAN or TINYINT | BOOLEAN |
| Upsert | MERGE | MERGE | MERGE | ON DUPLICATE KEY | ON CONFLICT |
12345678910111213141516171819202122232425
-- Standard SQL (SQL:2008)SELECT * FROM productsORDER BY priceOFFSET 20 ROWSFETCH FIRST 10 ROWS ONLY; -- MySQL / PostgreSQL (common approach)SELECT * FROM productsORDER BY priceLIMIT 10 OFFSET 20; -- SQL Server (legacy)SELECT TOP 10 * FROM productsORDER BY price; -- Doesn't support offset natively pre-2012 -- Oracle (legacy)SELECT * FROM ( SELECT p.*, ROWNUM rn FROM ( SELECT * FROM products ORDER BY price ) p WHERE ROWNUM <= 30)WHERE rn > 20; -- Notice: Same result, dramatically different syntaxSyntax differences are visible and relatively easy to handle. More dangerous are subtle semantic differences—cases where the same syntax produces different results. For example, NULL sorting order, string collation, and date/time handling vary significantly across databases.
Given the gap between standard SQL and real-world databases, how should you approach SQL development? Here are practical strategies for different scenarios.
A common architectural pattern: use standard SQL for core CRUD operations (which rarely need porting) and confine dialect-specific SQL to a thin database access layer. This way, switching databases requires changing one layer, not the entire codebase.
Testing for Portability:
If SQL portability is a requirement, testing is essential:
The SQL standard documents are publicly accessible (for a fee) through ISO and ANSI, but they are dense, formal specifications—not tutorials. Understanding how to read them is a specialized skill.
ISO/IEC 9075 documents are sold individually (around $150-200 per part) or as a collection. Draft versions are sometimes freely available. Academic institutions often have ISO subscriptions. For most developers, secondary sources (database documentation, books, articles) are more practical than the raw standard.
Standard Document Structure:
Each standard part follows a consistent structure:
BNF Grammar in SQL Standards:
SQL syntax is formally specified using Backus-Naur Form (BNF). Here's an example from the standard:
<query specification> ::=
SELECT [ <set quantifier> ] <select list>
<table expression>
<set quantifier> ::= DISTINCT | ALL
<select list> ::=
<asterisk>
| <select sublist> [ { <comma> <select sublist> }... ]
<select sublist> ::=
<derived column>
| <qualified asterisk>
This notation precisely defines what constitutes a valid SQL query. Learning to read BNF helps you understand exactly what the standard permits.
Rather than reading the raw standard, consider: PostgreSQL documentation (known for excellent standards coverage), 'SQL:2011: Temporal Data & the ISO/IEC 9075 Standard' by Kulkarni, and the 'use-the-index-luke.com' website for optimization-focused standards insights.
SQL standardization is a complex but essential topic for serious database work. Let's consolidate the key points:
What's Next:
With SQL's history and standards foundation established, we'll now explore the core characteristics that make SQL unique among programming languages. Understanding these characteristics—declarative nature, set-based operations, and strong typing—will deepen your appreciation of SQL's design philosophy.
You now understand how SQL standards are developed, their evolution over time, conformance levels, and the practical challenges of vendor-specific dialects. This knowledge enables you to write more portable SQL and make informed decisions about when to use standard versus proprietary features.