17.10 - Creating a New Transaction-Time Table - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - Temporal Table Support

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1182-171K
Language
English (United States)

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);