ANSI SQL Standard vs. Vendor Dialects Compared
AI generated
SELECT
JOIN
SQL · ANSI Standard · Portability · Database Comparison
ANSI SQL Standard vs. Vendor Dialects
what the standard actually mandates

The ANSI SQL standard defines less than many developers assume, and the major database systems rarely implement it in full. This article shows which parts of SQL are actually standardized, where PostgreSQL, MySQL, Oracle, and SQL Server use their own dialect extensions, and how to recognize whether a query is portable or not.

17 min read SQL:2016 · Standard Conformance · Dialect Features PostgreSQL · MySQL · Oracle · SQL Server

1. What the ANSI SQL standard actually is

The term ANSI SQL standard is often used in discussions as if there were a single, fixed specification that every database either satisfies or violates. In reality, the ANSI SQL standard, together with its international counterpart ISO/IEC 9075, is a multi part document that gets extended at regular intervals and distinguishes between mandatory core features (Core SQL) and optional extension packages. No single commercial database system implements the entire standard, and that is not even the goal of the specification.

The practical consequence: when someone says a query is "standard SQL", they usually mean it uses core SQL features that are interpreted the same way by most major systems, not that the query has been validated against the full specification. The ANSI SQL standard defines the syntax for SELECT, JOIN, WHERE, aggregate functions, and many other building blocks, but deliberately leaves room for vendor specific extensions, for example for stored procedures, procedural language extensions, or administrative commands that are naturally system specific.

2. From SQL-92 to SQL:2016: the key revisions

The evolution of the ANSI SQL standard shows how the language has expanded over decades. SQL-92 was for a long time the reference many database systems oriented themselves on, defining fundamental features such as subqueries, OUTER JOIN syntax, and integrity constraints. SQL:1999 added recursive queries via WITH RECURSIVE and object relational extensions. SQL:2003 brought window functions and the MERGE statement, both found in almost every modern system today, though with dialect specific differences.

SQL:2016 added native JSON support as a standard feature, an area where actual database implementations had gone their own way long before standardization. This is a recurring pattern with the ANSI SQL standard: database vendors implement a useful feature proprietarily first because the market demands it, and the standard follows years later with its own, often slightly different syntax. JSON operators are the most recent example that standardization usually trails practice instead of leading it.


-- SQL:1999 standard: recursive CTE for hierarchical data
WITH RECURSIVE org_chart AS (
    SELECT id, name, manager_id, 1 AS level
    FROM employees
    WHERE manager_id IS NULL

    UNION ALL

    SELECT e.id, e.name, e.manager_id, oc.level + 1
    FROM employees e
    JOIN org_chart oc ON e.manager_id = oc.id
)
SELECT * FROM org_chart ORDER BY level, name;

-- SQL:2003 standard: window function, supported with identical syntax
-- across PostgreSQL, MySQL 8+, Oracle, and SQL Server
SELECT
    department,
    employee_name,
    salary,
    RANK() OVER (PARTITION BY department ORDER BY salary DESC) AS salary_rank
FROM employees;

3. Standardized data types and where vendors diverge

The ANSI SQL standard defines a base set of data types: CHARACTER, NUMERIC, INTEGER, DATE, TIME, and TIMESTAMP are among them. In practice, all major systems offer these types under similar names, yet a closer look reveals differences. VARCHAR without a length specification is valid in PostgreSQL, but an error in many other systems. The standard type NUMERIC has a different default precision in Oracle than in PostgreSQL, and MySQL rounds certain numeric operations differently from what the standard prescribes.

The divergence becomes even clearer for types the ANSI SQL standard does not know at all: arrays, user defined enum types, geometric data types, and of course JSON native types such as JSONB are pure vendor extensions. Anyone writing code meant to run on multiple database systems must either avoid these proprietary types or encapsulate them behind an abstraction layer that chooses the appropriate implementation depending on the target database.

4. Standard syntax vs. proprietary shorthand

A classic example of the gap between the ANSI SQL standard and vendor dialects is pagination. Since SQL:2008, the standard defines the clause FETCH FIRST n ROWS ONLY combined with OFFSET n ROWS, syntax supported by Oracle, SQL Server (from version 2012), and PostgreSQL. MySQL, on the other hand, still prefers its own LIMIT clause to this day, which is shorter but not standard syntax. Anyone who wants to write portable code should use FETCH FIRST wherever practical, even though LIMIT dominates in many tutorials because it is shorter to type.

The same applies to string concatenation: the ANSI SQL standard defines the || operator, supported by PostgreSQL, Oracle, and SQL Server (in standard compatibility mode). MySQL instead uses the CONCAT() function by default. Since CONCAT() itself is not a strict standard construct but is supported by practically all systems, CONCAT() has established itself in practice as the more pragmatic, portable path, even though it does not match the original ANSI SQL standard syntax.


-- SQL:2008 standard: FETCH FIRST, supported by PostgreSQL, Oracle, SQL Server
SELECT id, name, price
FROM products
ORDER BY price DESC
OFFSET 20 ROWS
FETCH FIRST 10 ROWS ONLY;

-- MySQL-specific (not standard, but widely used): LIMIT
SELECT id, name, price
FROM products
ORDER BY price DESC
LIMIT 10 OFFSET 20;

5. Window functions: standardized, but implemented differently

Window functions have been part of the ANSI SQL standard since SQL:2003 and are among the most consistently implemented features across all major database systems. ROW_NUMBER(), RANK(), DENSE_RANK(), and the OVER clause with PARTITION BY and ORDER BY work almost identically in PostgreSQL, MySQL from version 8, Oracle, and SQL Server. This makes window functions a good example that standardization can work when there is enough market pressure and consensus.

Yet there are subtleties here too: the behavior of window frames (ROWS BETWEEN vs. RANGE BETWEEN) with tied values in the sort column differs in edge cases between systems, and not every database supports every frame variant defined by the standard, such as GROUPS. Anyone using window functions with more exotic frame definitions should check the concrete implementation of the target database instead of blindly relying on the ANSI SQL standard.

6. Common table expressions as a standard feature

Common table expressions (WITH clauses) are another example of a feature standardized since SQL:1999 and present in modern versions of all major databases. The basic syntax WITH cte_name AS (SELECT ...) is identical everywhere. Differences appear in advanced options: PostgreSQL allows MATERIALIZED and NOT MATERIALIZED as explicit optimization hints, while other systems leave that decision to the optimizer without giving the developer any influence.

Recursive CTEs with WITH RECURSIVE are also standard, though MySQL requires the RECURSIVE keyword explicitly, while SQL Server and older Oracle versions accept it without that keyword but with the same semantics. These small syntactic differences illustrate that even well standardized features are never implemented one hundred percent identically, because every vendor brings its own historical baggage and compatibility decisions.


-- Standard CTE syntax, works identically almost everywhere
WITH high_value_orders AS (
    SELECT customer_id, SUM(total) AS total_spent
    FROM orders
    GROUP BY customer_id
    HAVING SUM(total) > 1000
)
SELECT c.name, hvo.total_spent
FROM customers c
JOIN high_value_orders hvo ON hvo.customer_id = c.id
ORDER BY hvo.total_spent DESC;

-- PostgreSQL-specific optimization hint (non-standard extension)
WITH high_value_orders AS MATERIALIZED (
    SELECT customer_id, SUM(total) AS total_spent
    FROM orders
    GROUP BY customer_id
)
SELECT * FROM high_value_orders WHERE total_spent > 1000;

7. Popular features the standard does not know at all

Some of the most frequently used database features have no equivalent in the ANSI SQL standard at all, because they are too tightly coupled to the internal architecture of a specific system. Upsert syntax belongs here: ON CONFLICT in PostgreSQL and ON DUPLICATE KEY UPDATE in MySQL are pure dialect extensions, the standard only offers the considerably more cumbersome MERGE statement instead, which has been standardized since SQL:2003 but is rarely used in its full standard form in practice.

Replication commands, backup syntax, storage engine directives, and indexing hints such as USE INDEX or WITH (NOLOCK) are also pure vendor extensions with no counterpart in the ANSI SQL standard whatsoever. That is consistent, since the standard describes the logical query language, not the physical storage architecture of a specific database. Anyone who internalizes this boundary immediately understands why some SQL constructs are portable and others never will be, regardless of how many future standard revisions still appear.

8. Strategies for standard leaning, portable code

Anyone developing applications that need to run on multiple database systems, or simply wanting to write future proof code, should orient toward the ANSI SQL standard wherever practical. Concretely, that means: FETCH FIRST instead of LIMIT, CAST() instead of proprietary conversion functions, standard data types instead of vendor specific extensions, and deliberately avoiding stored procedure languages like PL/pgSQL or T-SQL in favor of application logic when portability is a priority.

At the same time, full standard conformance is rarely the right goal. Anyone deliberately committed only to PostgreSQL gives up performance and expressiveness by forgoing JSONB, GIN indexes, or MATERIALIZED CTEs just to stay theoretically portable. The pragmatic rule: use standard SQL for the core of application logic, apply dialect specific features deliberately and documented where they bring real value, and clearly mark those places in the code so a later database switch remains manageable.

9. Standard vs. dialect side by side

The following table classifies common SQL features by whether they are part of the ANSI SQL standard or a pure vendor extension.

Feature Standard Status Since Practical Note
Window Functions Standard SQL:2003 Very consistently implemented
Recursive CTEs Standard SQL:1999 RECURSIVE keyword requirement varies
FETCH FIRST Standard SQL:2008 MySQL still favors LIMIT
ON CONFLICT / ON DUPLICATE KEY Dialect No standard equivalent Standard only offers MERGE
JSONB / JSON Operators Partly Dialect JSON since SQL:2016 Operator syntax remains vendor specific

The table makes clear that the ANSI SQL standard is more of a growing common core than a complete specification of every practically needed feature. Newer functionality almost always emerges first as a vendor extension and is, if ever, standardized only years later, usually with its own syntax that differs slightly from the original proprietary implementation.

Mironsoft

SQL architecture, portability audits, and database strategy

Unsure how standard compliant your SQL really is?

We review existing codebases for dialect specific dependencies, assess migration risk, and develop a pragmatic strategy between standard conformance and the use of powerful vendor features.

Portability Audit

Systematic analysis of all dialect specific constructs in existing code

Architecture Consulting

Decision support between standard SQL and deliberate use of vendor features

Migration Preparation

Documentation of every spot requiring changes during a database switch

10. Summary

The ANSI SQL standard is not a complete rulebook that makes every database identical, but a growing common core that major systems approach to different degrees. Window functions and common table expressions are among the most consistently implemented standard features, while upsert syntax, proprietary data types, and administrative commands remain almost entirely vendor specific. Knowing this difference leads to more deliberate decisions about where portability is realistic and where it would mean unnecessarily giving up powerful features.

The pragmatic path rarely lies in radical standard loyalty and just as rarely in blind trust in vendor specific syntax. Instead, a deliberate, documented decision per feature pays off: if a standard alternative is available and performs well enough, use it. If a dialect extension brings a clear advantage, use it, but make it visible in a central place in the code so a later database switch does not become a surprise.

ANSI SQL Standard vs. Vendor Dialects: The Key Takeaways

What is standardized

Window functions, CTEs, base types, and core syntax such as SELECT, JOIN, WHERE are consistently standardized.

What is pure dialect extension

Upsert syntax, storage engines, replication, and most administrative commands have no standard equivalent.

Key standard recommendation

FETCH FIRST instead of LIMIT, CAST() instead of proprietary conversion, where portability matters.

Pragmatic rule

Standard for the core, documented dialect features only where they bring real value.

11. FAQ: ANSI SQL Standard vs. Vendor Dialects

1Does any database fully comply with the standard?
No, all systems implement a core area and add their own dialect extensions.
2ANSI SQL vs. ISO SQL, what is the difference?
Both bodies work on the same specification ISO/IEC 9075, the term ANSI SQL has become established historically.
3Are window functions standard?
Yes, since SQL:2003, and consistently implemented across major systems.
4Why does MySQL use LIMIT instead of FETCH FIRST?
Historical compatibility, LIMIT existed before FETCH FIRST was standardized.
5Is MERGE a good alternative to ON CONFLICT?
Standardized, but more cumbersome. For simple upserts, dialect syntax usually stays more pragmatic.
6What happens with only standard SQL?
More portability, but often less performance features. A deliberate balance is usually better.
7Are stored procedures standardized?
SQL/PSM exists as a standard, but PL/pgSQL, T-SQL, and PL/SQL differ substantially from it.
8Why does the standard feel so slow moving?
New revisions are rare, vendors implement them prioritized by market demand.
9Is standard SQL worthwhile for small tools?
Usually not necessary, the benefits of dialect specific features usually outweigh it there.
10How do I check if a feature is standard?
DBMS documentation and reference overviews of SQL:2016 usually give explicit information.