ISO SQL标准经历了SQL:2016, SQL:2011, SQL:2008, SQL:2006, SQL:2003(这个版本开始,根据主题拆分), SQL:1999, and SQL-92。
从上可知,SQL 2003是现代SQL的分水岭之一。
当前组成部分如下:
- ISO/IEC 9075-1 Framework (SQL/Framework)
- ISO/IEC 9075-2 Foundation (SQL/Foundation)
- ISO/IEC 9075-3 Call Level Interface (SQL/CLI)
- ISO/IEC 9075-4 Persistent Stored Modules (SQL/PSM)
- ISO/IEC 9075-9 Management of External Data (SQL/MED)
- ISO/IEC 9075-10 Object Language Bindings (SQL/OLB)
- ISO/IEC 9075-11 Information and Definition Schemas (SQL/Schemata)
- ISO/IEC 9075-13 Routines and Types using the Java Language (SQL/JRT)
- ISO/IEC 9075-14 XML-related specifications (SQL/XML)
- ISO/IEC 9075-15 Multi-dimensional arrays (SQL/MDA)
ISO/IEC 9075-14:2003 Information technology — Database languages — SQL — Part 14: XML-Related Specifications (SQL/XML)
ISO SQL Standard 2017 as Part 6 – SQL support for JavaScript Object Notation (JSON): ISO / IEC TR 19075-6: 2017 https://www.iso.org/standard/67367.html,https://www.buckenhofer.com/2019/01/json-and-iso-sql-standard/
https://www.postgresql.org/docs/current/features.html PG ISO/IEC SQL的实现情况,主要到SQL 2016。PostgreSQL内核覆盖了第1, 2, 9, 11, 和14部分,第3部分通过ODBC 驱动实现,第13部分通过PL/Java插件实现。第4, 10, 和15 部分当前无实现。
https://docs.oracle.com/database/121/SQLRF/ap_standard_sql.htm#SQLRF019
分析函数是ISO/IEC 2008的一部分
SQL 89只有平铺的from a,b,c
SQL 92包含了大量的增强,包括定义了外连接语法及集合,如下:
The next revision of the standard was SQL-92 – and it was a major revision. The language introduced by SQL-92 is sometimes referred to as SQL 2. The standard document grew from 120 to 579 pages. However, much of the growth was due to more precise specifications of existing features.
The most important new features were:
- An explicit
JOIN
syntax and the introduction of outer joins:LEFT JOIN
,RIGHT JOIN
,FULL JOIN
. - The introduction of
NATURAL JOIN
andCROSS JOIN 在语义分析时,natural join会被转换为USING。ON也一样,所以优先USING而非ON/NATURAL JOIN
- The introduction of set operations (set union, set intersection, and set difference).
- The introduction of the conditional expression
CASE WHEN
. - New scalar operations: string concatenation, substring extraction, and date and time mathematics.
- The
CAST
operator, which allows the explicit casting of values into types.
SQL-92 also introduced new data definition statements: ALTER
and DROP
for tables and views, and new data types (date
, time
, timestamp
, interval
, bit
string, varchar
string, and national character
strings). This version added an information schema (the standard way to get database metadata, such as table names, table columns, column types, and table constraints). It also introduced temporary tables, transaction isolation levels, and the dynamic execution of queries (dynamic SQL).