iso sql标准发展及各个版本定义的特性
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).
ISO/IEC 9075 - SQL Standard
SQL-86 (or SQL-87)
- transactions
- create
- read
- update
- delete
SQL-89
SQL-92
- subqueries in place of named tables.
- Internationalization.
- Embedded SQL in programming languages
SQL:1999
SQL:2003
merge
statement and the second of two collection types: the multiset.Data types
bit
and bit varying
data types were removed from the standard. (However, SQL Server still has the bit
datatype).bigint
multiset
(which is a collection type).XML
Columns
- identity columns, and
- generated columns
SQL:2006
SQL:2008
merge
statement.SQL:2011
delete
in themerge
statement.- Pipelined DML
- Enhanced
call
statement (named arguments and default values for arguments) - Ability to limit fetches (See Oracle SQL: select first n rows / rows between n and m (top n/limit queries))
- Enhanced collection types
- Non-enforced table constraints
- Window enhancement (
ntile
, navigation within a window (lag
,lead
,nth_value
,first
andlast
), nested navigation within a window,groups
option)
SQL:2016
- Support for JSON data (of the 44 new optional features of SQL:2016, 22 are related to JSON).
- Polymorphic table functions (PTF)
- Row pattern recognition (RPR): apply regular expressions across rows.
- Trigonometric and logarithmic functions
Support for JSON
varchar
or clob
).Row pattern recognition (RPR)
Polymorphic table functions (PTF)
SQL:2019
SQL:2020
- Better support for Big Data applications.
- Graph queries
- Approximate queries/aggregates and uncertain data.
- Integration of statistical packages (for example R).
- Support for map-reduce algorithms
- Streaming/continuous queries
- Support for blockchains
- BASE transactions
Parts of the standard
- 1: Framework
- 2: Foundation
- 3: Call-Level Interface (CLI)
- 4: Persistent Stored Modules (PSM) - for example PL/SQL for Oracle or T-SQL for SQL Server.
- 9: Management of External Data (MED)
- 10: Object Language Bindings (OLB)
- 11: Information and Definition Schemas (Schemata)
- 13: SQL Routines and Types using the Java Programming Language (JRT)
- 14: XML-Related Specification
- 15: Multidimensional arrays (MDA) (Published June 2019)
- 16: Property Graph Query (SQL/PGQ) - Apparently being worked on for SQL:2020?
Part 2
- Data types
- DDL
- Querying:
select
,join
etc. - DML:
insert
,update
,delete
,merge
… - Access Control:
grant
,revoke
- Transaction control:
commit
,rollback
, … - Connection management:
connect
,disconnect
- Session management:
set session
- Exception handling:
get diagnostics
Mandatory and optional features
- mandatory
- optional
(F|S|T)\d\d\d
(for example F314
is merge statement with DELETE branch).Not freely publicly available
Technical reports
- ISO/IEC TR 19075-1: XQuery Regular Expression Support in SQL
- ISO/IEC TR 19075-2: SQL Support for TimeRelated Information
- ISO/IEC TR 19075-3: SQL Embedded in Programs using the Java programming language
- ISO/IEC TR 19075-4: SQL with Routines and types using the JavaTM programming language
- ISO/IEC TR 19075-5: Row Pattern Recognition in SQL
- ISO/IEC TR 19075-6: SQL support for JSON
- ISO/IEC TR 19075-7: SQL Support for Polymorphic Table Functions
- ISO/IEC TR 19075-8: SQL Support for multi dimensional arrays
Misc
create database
statement. In fact, the SQL standard does neither define nor use the word database (except for constructs like «database application» or «database access» and in its title).create index
statement.