One standard, many dialects
SQL has one formal standard family, ISO/IEC 9075. ANSI published the first edition in 1986 and ISO followed in 1987, and new editions have added features since then. In everyday use, though, people usually mean the dialect of a specific database product, such as Microsoft’s T-SQL, Oracle’s PL/SQL, PostgreSQL, MySQL or SQLite. Products support most of the standard and add their own features on top, so the same question can need different syntax in each.
The standard editions
These are the main editions. Sources give slightly different dates for some of the early ones, so check the ISO/IEC 9075 documents for exact publication dates.
- SQL-86 was the first formal standard, published by ANSI in 1986 and by ISO in 1987.
- SQL-89 was a minor revision that added integrity constraints.
- SQL-92 was a major revision, also called SQL2.
- SQL:1999 added regular expressions, recursive queries, triggers and some object-oriented features.
- SQL:2003 added XML-related features, window functions and identity columns.
- SQL:2006 added a part covering SQL with XML and XQuery.
- SQL:2008 added INSTEAD OF triggers, the TRUNCATE statement and the FETCH clause.
- SQL:2011 added support for temporal data and improved window functions.
- SQL:2016 added row pattern matching and JSON operations.
- SQL:2019 added support for multidimensional arrays.
- SQL:2023 added a JSON data type and property graph queries.
Dialects you will meet
Most database products support the core of the standard plus extras. The differences you will notice early include:
- Row limits. SQL Server uses TOP (and OFFSET … FETCH). MySQL, PostgreSQL and SQLite use LIMIT.
- Joining text. The standard uses
||, and PostgreSQL and SQLite do too. SQL Server uses+. In MySQL,||is a logical OR unless the PIPES_AS_CONCAT mode is on. For how||behaves, see “What is the use of || in SQL?” - Procedural code. Oracle’s PL/SQL, SQL Server’s Transact-SQL (T-SQL) and PostgreSQL’s PL/pgSQL each add variables, loops and stored procedures in their own language.
- Dates and type names. Date functions and type names vary the most, so check the product’s manual for exact syntax.
Products people compare
Database names are easy to mix up. MariaDB started as a fork of MySQL, so the two share much of their syntax and differ in other places. For a side-by-side look at specific releases, see MySQL 8 vs MariaDB 10.6.
Terms such as database, DBMS and product also get blurred. “Is MySQL a DB or DBMS?” untangles that. Rankings of the most widely used SQL databases vary by source and by year, so for one view, see “What are the top 5 SQL databases?”
Which version should you learn?
Learn core standard SQL first: SELECT, joins, GROUP BY, subqueries and data types. That knowledge carries over to almost every product. Then learn the dialect of the database you will use at work or school. If an employer uses a particular product, follow its dialect.
If you are still choosing a practice database, PostgreSQL is known for close adherence to the standard, which makes it a good place to learn. SQLite is another option, because it needs no server and runs on a laptop.