Syntax - Advanced SQL Engine - Teradata Database

Temporal Table Support

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
cjo1556732840654.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1182
lifecycle
previous
Product Category
Teradata Vantage™
Teradata Vantage™ - Temporal Table Support describes syntax that is especially relevant to temporal tables. Syntax that is not required, or that is not otherwise specific to temporal tables is generally not shown in this document. For additional syntax, see Teradata Vantage™ - SQL Data Definition Language Syntax and Examples, B035-1144 , Teradata Vantage™ - SQL Data Manipulation Language, B035-1146 , and Teradata Vantage™ - SQL Data Control Language, B035-1149.
[ { CURRENT | NONSEQUENCED } VALIDTIME |
  [ SEQUENCED ] VALIDTIME [ period_expression ] |
  NONTEMPORAL
]
update_statement [;]
To ensure application portability to ANSI standards for temporal SQL, Teradata recommends explicit specification of all temporal qualifiers.
CURRENT VALIDTIME
Specifies that the update is current in the valid-time dimension if the target table supports valid time.
A current UPDATE affects only current rows. Future rows with valid-time periods that do not overlap TEMPORAL_TIMESTAMP or TEMPORAL_DATE will not be updated

If the target table does not support valid time, at least one of the referenced tables must be a table with valid time. The update is not a current update. The CURRENT VALIDTIME qualifier is used to qualify rows from the referenced tables in the valid-time dimension. In the transaction-time dimension, open rows qualify.

If the session temporal qualifier is not set and the temporal qualifier is omitted from the UPDATE statement, the default qualifier is CURRENT VALIDTIME.

CURRENT DML modifications can cause serializability issues for concurrent transactions. See Potential Concurrency Issues with Current Temporal DML for information on avoiding these issues.
VALIDTIME and SEQUENCED VALIDTIME
Specifies that the update is sequenced in the valid-time dimension if the target table supports valid time.

If the target table does not support valid time, at least one of the referenced tables must be a table with valid time. The update is not a sequenced update. The VALIDTIME or SEQUENCED VALIDTIME qualifier is used to qualify rows from the referenced tables in the valid-time dimension. In the transaction-time dimension, open rows qualify.

A sequenced update on a target table that supports valid time sets the valid-time value to the intersection of the valid-time column value and period_expression.

period_expression

Specifies the period of applicability for the DML statement.

The period of applicability must be a period constant expression that does not reference any columns, but can reference parameterized values and the TEMPORAL_DATE or TEMPORAL_TIMESTAMP built-in functions.

The period of applicability can also be a self-contained noncorrelated scalar subquery that is always nonsequenced in the time dimensions regardless of the temporal qualifier for the DML statement.

If a period_expression is specified, the valid-time column cannot be specified or referenced anywhere in the query. If the valid-time column is a derived period column, the component columns cannot be specified or referenced anywhere in the query.

If period_expression is omitted, the period of applicability defaults to PERIOD'(0001-01-01, UNTIL_CHANGED)' for a PERIOD(DATE) valid-time column or PERIOD '(0001-01-01 00:00:00.000000+00:00, UNTIL_CHANGED)' for a PERIOD(TIMESTAMP( n ) WITH TIME ZONE) valid-time column, where precision n and WITH TIME ZONE are optional.

NONSEQUENCED VALIDTIME
Specifies that the update is nonsequenced in the valid-time dimension if the target table supports valid time.

If the target table does not support valid time, at least one of the referenced tables must be a table with valid time. The update is not a nonsequenced update. The NONSEQUENCED VALIDTIME qualifier is used to qualify rows from the referenced tables in the valid-time dimension. In the transaction-time dimension, open rows qualify.

NONTEMPORAL
Specifies that the update is nonsequenced in the valid-time dimension and nontemporal in the transaction-time dimension.

A nontemporal update treats the transaction-time column as a nontemporal column.

The table must support transaction time.

update_statement
Specifies conventional syntax for the UPDATE statement.
For a current or sequenced update on a table with valid time, the SET clause cannot reference the valid-time column as the name of the column whose data is to be updated.

For an update on a table with transaction time, the SET clause cannot reference the transaction-time column as the name of the column whose data is to be updated, unless the NONTEMPORAL qualifier is used.

The SET clause cannot use CURRENT_DATE or CURRENT_TIMESTAMP in the expressions that are used to assign a value to the valid-time column.