Example: Override TD_TIMECODE as the DEFAULT TIMECODE Column - Analytics Database - Teradata Vantage

Time Series Tables and Operations

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2023-10-30
dita:mapPath
tuc1628112453431.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
sfz1493079039055
lifecycle
latest
Product Category
Teradata Vantageā„¢

PTI tables have their own timecode column. To override TD_TIMECODE as the default timecode column, specify it in the USING TIMECODE clause. For example, suppose the OCEAN_BUOYS table had another column called my_timecode that was of TIMESTAMP(6) type. Note that when the USING TIMECODE clause is not specified, the timecode column is the default system generated TD_TIMECODE column when a PTI table is given in the query:

-- use default timecode TD_TIMECODE
select avg(temperature)
from ocean_buoys
group by time(minutes(10));
  
-- override default
create table my_ocean_buoys as ocean_buoys with no data;
alter table my_ocean_buoys add my_timecode timestamp(6);
show table my_ocean_buoys;
CREATE SET TABLE my_ocean_buoys ,NO FALLBACK ,
     NO BEFORE JOURNAL,
     NO AFTER JOURNAL,
     CHECKSUM = DEFAULT,
     DEFAULT MERGEBLOCKRATIO
     (
      TD_TIMEBUCKET BIGINT NOT NULL GENERATED SYSTEM TIMECOLUMN,
      TD_TIMECODE TIMESTAMP(6) NOT NULL GENERATED TIMECOLUMN,
      BUOYID INTEGER,
      SALINITY INTEGER,
      TEMPERATURE INTEGER,
      my_timecode TIMESTAMP(6))
PRIMARY TIME INDEX (TIMESTAMP(6), DATE '2012-01-01', HOURS(1), COLUMNS(BUOYID), NONSEQUENCED);

-- use my_timecode instead of TD_TIMECODE. 
select avg(temperature)
from my_ocean_buoys
group by time(minutes(100))
using timecode(my_timecode);