17.05 - Creating a New Transaction-Time Table - Teradata Database

Teradata Vantage™ - Temporal Table Support

prodname
Advanced SQL Engine
Teradata Database
vrm_release
17.00
17.05
created_date
June 2020
category
Programming Reference
featnum
B035-1182-170K

To create a transaction-time table, use a normal CREATE TABLE statement, and define one column of the table as a transaction-time column. The data type of the column can be derived from two TIMESTAMP(6) WITH TIME ZONE columns, or can be a single PERIOD(TIMESTAMP(6) WITH TIME ZONE) column, and must use the TRANSACTIONTIME or AS TRANSACTIONTIME column attribute. Transaction-time columns must also specify the NOT NULL column attribute.

Example: Creating a Derived Period Transaction-Time Table

   CREATE MULTISET TABLE Policy_Types (
      Policy_Name VARCHAR(20),
      Policy_Type CHAR(2) NOT NULL PRIMARY KEY,
      Policy_Start TIMESTAMP(6) WITH TIME ZONE NOT NULL,
      Policy_End TIMESTAMP(6) WITH TIME ZONE NOT NULL,
      PERIOD FOR Policy_Duration(Policy_Start,Policy_End)
         AS TRANSACTIONTIME
      )
   PRIMARY INDEX (Policy_Name);

Example: Creating a Period Data Type Transaction-Time Table

   CREATE MULTISET TABLE Policy_Types (
      Policy_Name VARCHAR(20),
      Policy_Type CHAR(2) NOT NULL PRIMARY KEY,
      Policy_Duration PERIOD(TIMESTAMP(6) WITH TIME ZONE) NOT NULL
         AS TRANSACTIONTIME
      )
   PRIMARY INDEX (Policy_Name);