| SQL language revisions |
|---|
SQL:2011 orISO/IEC 9075:2011 (under the general title "Information technology – Database languages – SQL") is the seventh revision of theISO (1987) andANSI (1986) standard for theSQLdatabasequery language. It was formally adopted in December 2011.[1] The standard consists of 9 parts which are described in detail inSQL.The next version isSQL:2016.
One of the main new features is improved support fortemporal databases.[2][3] Language enhancements for temporal data definition and manipulation include:
PERIODFOR annotationWITHOUTOVERLAPS clauseCONTAINS,OVERLAPS,EQUALS,PRECEDES,SUCCEEDS,IMMEDIATELYPRECEDES andIMMEDIATELYSUCCEEDS (which are modified versions ofAllen’s interval relations)PERIODFORSYSTEM_TIME annotation andWITHSYSTEMVERSIONING modifier. System time periods are maintained automatically. Constraints for system-versioned tables are not required to be temporal and are only enforced on current rowsASOFSYSTEMTIME andVERSIONSBETWEENSYSTEMTIME...AND... clausesSAP HANA 2.0 SP03 supports system-versioned tables[4] using the standard select syntaxFORSYSTEM_TIMEASOF'<timestamp1>'[5]SAP HANA 2.0 SP04 adds (partial) support for application-time versioning[6]
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",[7][8] although they use the alternative syntaxFORSYSTEM_TIMEASOF.
Oracle 12c supports temporal functionality in compliance with SQL:2011.[9] Versions 9,[10][11] 10g and 11g implement thetime-sliced queries in what they callFlashback Queries, using the alternative syntaxASOFTIMESTAMP.[12] 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 withSYSTEM_VERSIONING.[13]
MariaDB 10.3 implements system-versioned tables.[14] MariaDB 10.4.3 added support for application-versioned tables.[15]
PostgreSQL requires installation of thetemporal_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 andMySQL usingtriggers, history tables and views.
CockroachDB has supportedASOFSYSTEMTIME queries since at leastv1.0.7.[16][17]