17.10 - Example: Sequenced Valid-Time Insert into a Bitemporal 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)

A sequenced valid-time insert is similar to a conventional insert, where the valid-time column is treated as any other column in the table. Use a sequenced valid-time insert to insert rows that are history, current, or future in the valid-time dimension.

All such insertions are open in the transaction-time dimension. Because the system automatically inserts the value for the transaction-time column, the INSERT statement cannot specify a value for the transaction-time column.

Consider the following bitemporal table:

   CREATE MULTISET TABLE Policy_History(
      Policy_ID INTEGER,
      Customer_ID INTEGER,
      Policy_Type CHAR(2) NOT NULL,
      Policy_Details CHAR(40),
      Validity PERIOD(DATE) NOT NULL AS VALIDTIME,
      Policy_Duration PERIOD(TIMESTAMP(6) WITH TIME ZONE) NOT NULL
         AS TRANSACTIONTIME)
   PRIMARY INDEX(Policy_ID);

The following statements perform sequenced valid-time inserts that are open in the transaction-time dimension into the Policy_History table.

   SEQUENCED VALIDTIME INSERT INTO Policy_History
      VALUES (232540, 909234455, 'BM', 'STD-CH-344-YYY-00',
         PERIOD (DATE '1999-01-01', DATE '1999-12-31'));

   SEQUENCED VALIDTIME INSERT INTO Policy_History
      (Policy_ID, Customer_ID, Policy_Type, Policy_Details, Validity)
      VALUES (944540, 344567123, 'BM', 'STD-PL-332-YXY-01',
         PERIOD (DATE '2007-02-03', DATE '2008-02-02'));