Example: Creating a Table Partitioned with Orders Data - Analytics Database - Teradata Vantage

SQL Functions, Expressions, and Predicates

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
2024-01-12
dita:mapPath
obm1628111499646.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
kby1472250656485
lifecycle
latest
Product Category
Teradata Vantageā„¢

The following example creates a table partitioned with orders data for each quarter in 2008.

   CREATE TABLE Orders
     (O_orderkey INTEGER NOT NULL,
      O_custkey INTEGER,
      O_orderperiod PERIOD (DATE) NOT NULL,
      O_orderpriority CHAR (21),
      O_comment VARCHAR (79))
     PRIMARY INDEX (O_orderkey)
     PARTITION BY
        CASE_N (END (O_orderperiod) <= date'2008-03-31', /* First Quarter */
                END (O_orderperiod) <= date'2008-06-30', /* Second Quarter */
                END (O_orderperiod) <= date'2008-09-30', /* Third Quarter */
                END (O_orderperiod) <= date'2008-12-31' /* Fourth Quarter */
                );

The following SELECT statement scans two partitions and displays the details of the orders placed for the first two quarters.

SELECT * 
FROM Orders 
WHERE END (O_orderperiod) > date'2008-06-30';