15.10 - Example: CASE_N Partitioning Expression Using the END Bound Function - Teradata Database

Teradata Database SQL Data Definition Language Syntax and Examples

prodname
Teradata Database
vrm_release
15.10
created_date
December 2015
category
Programming Reference
featnum
B035-1144-151K

This example creates a table whose primary index is partitioned using a CASE_N expression and END bound functions.

     CREATE TABLE orders (
       o_orderkey      INTEGER NOT NULL,
       o_custkey       INTEGER,
       o_orderperiod   PERIOD(DATE) NOT NULL
       o_orderpriority CHARACTER(21),
       o_comment       VARCHAR(79))
     PRIMARY INDEX (o_orderkey)
     PARTITION BY CASE_N (END(o_orderperiod) <= DATE '2010-03-31',/*Q1*/
                          END(o_orderperiod) <= DATE '2010-06-30',/*Q2*/
                          END(o_orderperiod) <= DATE '2010-09-30',/*Q3*/
                          END(o_orderperiod) <= DATE '2010-12-31' /*Q4*/
                         );