Example: Current and Historical Partitioning Using CURRENT_DATE in a CASE_N Expression - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

This example partitions a stock table into historical and current partitions. (The table movedate.stock is on the Block File System.)

     CREATE TABLE movedate.stock (
       stock_name         CHARACTER(8),
       stock_code         INTEGER,
       stock_price        DECIMAL(10,6)
       stock_pricing_time TIMESTAMP(6) WITH TIME ZONE)
     PRIMARY INDEX (stock_code, stock_pricing_time)
     PARTITION BY CASE_N(stock_pricing_time >= CURRENT_TIMESTAMP, 
                  NO CASE);

The output of a SHOW TABLE request on stock displays the user-specified partitioning expression as a TIMESTAMP.

     SHOW TABLE movedate.stock;
     CREATE SET TABLE movedate.stock, NO FALLBACK, 
          NO BEFORE JOURNAL,
          NO AFTER JOURNAL,
          CHECKSUM = DEFAULT (
           stock_name         CHARACTER(8) CHARACTER SET LATIN 
                              NOT CASESPECIFIC,
           stock_code         INTEGER,
           stock_price        DECIMAl(10,6)
           stock_pricing_time TIMESTAMP(6) WITH TIME ZONE)
     PRIMARY INDEX (stock_code ,stock_pricing_time)
     PARTITION BY CASE_N(stock_pricing_time >= CURRENT_TIMESTAMP(6), 
     NO CASE);