SQL:2011
{{Short description|2011 edition of the SQL standard}}
{{SQL language revisions}}
SQL:2011 or ISO/IEC 9075:2011 (under the general title "Information technology – Database languages – SQL") is the seventh revision of the ISO (1987) and ANSI (1986) standard for the SQL database query language. It was formally adopted in December 2011.{{Citation | publisher = Sybase | url = http://iablog.sybase.com/paulley/?p=2612 | archive-url = https://archive.today/20120711002304/http://iablog.sybase.com/paulley/?p=2612 | url-status = dead | archive-date = July 11, 2012 | date = December 16, 2011 | contribution = SQL:2011 is published | title = IA | format = blog | last = Paulley }} The standard consists of 9 parts which are described in detail in SQL.
The next version is SQL:2016.
New features
One of the main new features is improved support for temporal databases.Zemke, Fred. "[http://www.sigmod.org/publications/sigmod-record/1203/pdfs/10.industry.zemke.pdf What's new in SQL:2011] {{Webarchive|url=https://web.archive.org/web/20130810193539/http://www.sigmod.org/publications/sigmod-record/1203/pdfs/10.industry.zemke.pdf |date=2013-08-10 }}". ACM SIGMOD Record 41.1 (2012): 67-73Kulkarni, Krishna, and Jan-Eike Michels. "[http://www.sigmod.org/publications/sigmod-record/1209/pdfs/07.industry.kulkarni.pdf Temporal features in SQL: 2011] {{Webarchive|url=https://web.archive.org/web/20121115034718/http://www.sigmod.org/publications/sigmod-record/1209/pdfs/07.industry.kulkarni.pdf |date=2012-11-15 }}". ACM SIGMOD Record 41.3 (2012): 34-43 Language enhancements for temporal data definition and manipulation include:
- Time period definitions use two standard table columns as the start and end of a named time period, with closed set-open set semantics. This provides compatibility with existing data models, application code, and tools
- Definition of application time period tables (elsewhere called valid time tables), using the {{code|PERIOD FOR|sql}} annotation
- Update and deletion of application time rows with automatic time period splitting
- Temporal primary keys incorporating application time periods with optional non-overlapping constraints via the {{code|WITHOUT OVERLAPS|sql}} clause
- Temporal referential integrity constraints for application time tables
- Application time tables are queried using regular query syntax or using new temporal predicates for time periods including {{code|CONTAINS|sql}}, {{code|OVERLAPS|sql}}, {{code|EQUALS|sql}}, {{code|PRECEDES|sql}}, {{code|SUCCEEDS|sql}}, {{code|IMMEDIATELY PRECEDES|sql}} and {{code|IMMEDIATELY SUCCEEDS|sql}} (which are modified versions of Allen’s interval relations)
- Definition of system-versioned tables (elsewhere called transaction time tables), using the {{code|PERIOD FOR SYSTEM_TIME|sql}} annotation and {{code|WITH SYSTEM VERSIONING|sql}} modifier. System time periods are maintained automatically. Constraints for system-versioned tables are not required to be temporal and are only enforced on current rows
- Syntax for time-sliced and sequenced queries on system time tables via the {{code|AS OF SYSTEM TIME|sql}} and {{code|VERSIONS BETWEEN SYSTEM TIME ... AND ...|sql}} clauses
- Application time and system versioning can be used together to provide bitemporal tables
=Support in database management systems=
SAP HANA 2.0 SP03 supports system-versioned tables{{Cite web|url=https://help.sap.com/viewer/4fe29514fd584807ac9f2a04f6754767/2.0.03/en-US/20d329a6751910149d5fdbc4800f92ff.html#loio20d329a6751910149d5fdbc4800f92ff__system_versioning_configuration|title = SAP Help Portal}} using the standard select syntax {{code|FOR SYSTEM_TIME AS OF '
IBM DB2 version 10 claims to be the first database to have a conforming implementation of this feature in what they call "Time Travel Queries",{{Cite web|url=http://www.ibm.com/developerworks/data/library/techarticle/dm-1204whatsnewdb210/index.html|title=Data management|website=IBM}}{{Cite web|url=http://www.ibm.com/developerworks/data/library/techarticle/dm-1204db2temporaldata/|title = Data management|website = IBM}} although they use the alternative syntax {{code|FOR SYSTEM_TIME AS OF|sql}}.
Oracle 12c supports temporal functionality in compliance with SQL:2011.{{cite web | url=http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/12c/r1/ilm/temporal/temporal.html | title=Implementing Temporal Validity }} Versions 9,{{Cite web|url=https://www.oracle-developer.net/display.php?id=210|title=flashback query in oracle 9i|website=www.oracle-developer.net|access-date=2024-11-01|lang=en}}{{Cite web|url=https://oracle-base.com/articles/9i/flashback-query|title=Flashback Query|lang=en|website=oracle-base.com|access-date=2024-11-01}} 10g and 11g implement the time-sliced queries in what they call Flashback Queries, using the alternative syntax {{code|AS OF TIMESTAMP|sql}}.{{Cite web|url=http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_10002.htm|title = Database SQL Reference}} Notably both of Oracle's implementations depend on the database's rollback segment and so only allow temporal queries against recent changes which are still being retained for backup.
Microsoft SQL Server (version 2016) implements temporal tables with {{code|SYSTEM_VERSIONING|sql}}.{{Cite web|url=https://msdn.microsoft.com/en-us/library/dn935015.aspx|title=Temporal Tables - SQL Server|date=16 October 2023 }}
MariaDB 10.3 implements system-versioned tables.{{Cite web|url=https://mariadb.com/kb/en/library/changes-improvements-in-mariadb-103/|title = Changes & Improvements in MariaDB 10.3}} MariaDB 10.4.3 added support for application-versioned tables.{{Cite web|url=https://mariadb.com/kb/en/application-time-periods/|title = Application-Time Periods}}
PostgreSQL requires installation of the [https://github.com/arkhipov/temporal_tables temporal_tables extension]. Temporal Tables Extension supports the system-period temporal tables only, but does not follow the SQL:2011 design.
Ebean ORM supports History AS OF and VERSIONS BETWEEN queries on PostgreSQL and MySQL using [https://ebean.io/docs/features/history triggers, history tables and views].
CockroachDB has supported {{code|AS OF SYSTEM TIME|sql}} queries since at least [https://www.cockroachlabs.com/docs/v1.0/as-of-system-time.html v1.0.7].{{Cite web|url=https://www.cockroachlabs.com/docs/stable/as-of-system-time.html|title = AS OF SYSTEM TIME | CockroachDB Docs}}{{Cite news|url=https://www.cockroachlabs.com/blog/time-travel-queries-select-witty_subtitle-the_future/|title = Time-Travel Queries: SELECT witty_subtitle FROM THE FUTURE| newspaper=Cockroach Labs |date = 22 June 2016}}
See also
{{Wikibook|Structured Query Language}}
References
{{Reflist}}
External links
- {{Citation | url = http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=53681 | contribution = SQL:2011 | title = Catalogue | publisher = ISO | format = webshop}}.
- {{Citation | publisher = JTC1SC32 | url = http://www.jtc1sc32.org/doc/N2151-2200/32N2153T-text_for_ballot-FDIS_9075-1.pdf | format = draft; PDF| date = 2011-08-06 | title = Part 1: Framework (SQL/Framework)}}.
- {{Citation | publisher = JTC1SC32 | url = http://www.jtc1sc32.org/doc/N2151-2200/32N2157T-text_for_ballot-FDIS_9075-14.pdf | format = draft; PDF | date = 2011-08-06 | title = Part 14: XML-Related Specifications (SQL/XML)}}.
- {{Citation | url = https://www.google.com/search?q=intitle%3A%22final+committee+draft+%22+intitle%3A9075+site%3Ajtc1sc32.org+2011 | title = List of further freely available Final Committee Drafts | format = search}}.
- {{Citation | url = http://www.oracle.com/technetwork/database/focus-areas/storage/total-recall-whitepaper-171749.pdf | title = Oracle 11g Total Recall Whitepaper | publisher = Oracle | date = 2009-09-01}}.
{{SQL}}