17.05 - Example: Dropping a Valid-Time Column - 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 drop a valid-time column from a valid-time table, use the ALTER TABLE statement.

Consider the following valid-time table:

   CREATE MULTISET TABLE Customer (
      Customer_Name VARCHAR(40),
      Customer_ID INTEGER,
      Customer_Address VARCHAR(80),
      Customer_Phone VARCHAR(12),
      Customer_Validity PERIOD(DATE) NOT NULL AS VALIDTIME
      )
   PRIMARY INDEX ( Customer_ID );

The following statement drops the Customer_Validity column:

   ALTER TABLE Customer DROP Customer_Validity;

To drop a valid-time column from a bitemporal table, use the ALTER TABLE statement and specify the NONTEMPORAL qualifier. Dropping any type of column from a bitemporal table requires the NONTEMPORAL privilege on the table, and the NONTEMPORAL qualifier to ALTER TABLE must be used.

Consider the following bitemporal table:

   CREATE MULTISET TABLE Customer (
      Customer_Name VARCHAR(40),
      Customer_ID INTEGER,
      Customer_Address VARCHAR(80),
      Customer_Phone VARCHAR(12),
      Customer_Validity PERIOD(DATE) NOT NULL AS VALIDTIME,
      Customer_Duration PERIOD(TIMESTAMP(6) WITH TIME ZONE) NOT NULL
         AS TRANSACTIONTIME
      )
   PRIMARY INDEX ( Customer_ID );

The following statement drops the Customer_Validity column:

   NONTEMPORAL ALTER TABLE Customer DROP Customer_Validity;

When a valid-time column is dropped from a bitemporal table, all rows that are no longer valid (all history rows in the valid-time dimension) are physically deleted from the table.