17.10 - Creating a New Valid-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 valid-time table, use a normal CREATE TABLE statement, and define one column as a valid-time column. The valid-time column can either be derived from two DATE, TIMESTAMP, or TIMESTAMP[(n)] WITH TIME ZONE columns, or can be a single Period data type column: PERIOD(DATE), PERIOD(TIMESTAMP[(n)]), or PERIOD(TIMESTAMP[(n)] WITH TIME ZONE). Use the VALIDTIME or AS VALIDTIME column attribute to assign the column to be the valid-time column.

Example: Creating a Derived Period Valid-Time Column

   CREATE MULTISET TABLE Policy(
      Policy_ID INTEGER,
      Customer_ID INTEGER,
      Policy_Type CHAR(2) NOT NULL,
      Policy_Details CHAR(40),
      Policy_Start DATE NOT NULL,
      Policy_End DATE NOT NULL,
      PERIOD FOR Validity(Policy_Start,Policy_End) AS VALIDTIME
      )
   PRIMARY INDEX(Policy_ID);

Example: Creating a Period Data Type Valid-Time Column

   CREATE MULTISET TABLE Policy(
      Policy_ID INTEGER,
      Customer_ID INTEGER,
      Policy_Type CHAR(2) NOT NULL,
      Policy_Details CHAR(40),
      Validity PERIOD(DATE) NOT NULL AS VALIDTIME
      )
   PRIMARY INDEX(Policy_ID);