15.00 - Views on Temporal Tables - Teradata Database

Teradata Database Temporal Table Support

prodname
Teradata Database
vrm_release
15.00
category
Programming Reference
featnum
B035-1182-015K

Views on Temporal Tables

The following examples create views on temporal tables.

Example  

The following statement creates a sequenced view on the Policy table. The result of the sequenced query is a valid-time table or, in this case, view. The valid-time period for each row in the view is stored in a new column that is automatically appended by the system. The valid-time for each row in the view is the overlap of the valid-time period of the row in the original temporal table with the valid time of the sequenced query. In this case, because a time period is not specified in the sequenced query, the period for the query defaults to (0001-01-01, UNTIL_CHANGED), and the valid-time periods in the view will match those for the original rows.

Because names for the view columns are not specified in the CREATE VIEW statement, the system assigns the new valid-time column the name VALIDTIME.

   CREATE VIEW Basic_Auto_Policy_V AS
   SEQUENCED VALIDTIME 
   SELECT Policy_ID, Customer_ID
   FROM Policy
   WHERE Policy_Type = 'AU';

Example  

The following statement creates a similar sequenced view on the Policy table but provides a list of column names that includes the extra column name “Basic_View_Validity”, which the system assigns to the new valid-time column that is appended to the view.

   CREATE VIEW Basic_Auto_Policy_V (
      Policy_ID,
      Customer_ID,
      Basic_View_Validity
      ) AS 
   SEQUENCED VALIDTIME 
   SELECT Policy_ID, Customer_ID
   FROM Policy
   WHERE Policy_Type = 'AU';

Example  

The following statement employs a business calendar function in an AS OF clause to define a view that shows insurance policies valid at the beginning of the current year.

CREATE VIEW ValidePoliciesOnJan1 AS
  VALIDTIME AS OF TD_YEAR_BEGIN(CURRENT_DATE) SELECT * FROM Policy;