Example: Dropping a Column from a Column Partition and Modifying it to Become a Two-Column Partition - Advanced SQL Engine - Teradata Database

SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.00
Published
September 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
wgr1555383704548.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1144
lifecycle
previous
Product Category
Teradata Vantage™

This example drops a column from a column partition of orders and modifies that partition to become a two-column partition with system-determined COLUMN format and autocompression.

     ALTER TABLE orders 
     DROP o_comment_ext2;

This results in the following table definition.

     CREATE TABLE orders (
       o_orderkey       INTEGER NOT NULL,
       o_custkey        INTEGER,
       o_orderstatus    CHARACTER(1) CASESPECIFIC,
       o_totalprice     DECIMAL(13,2) NOT NULL,
       o_ordertsz       TIMESTAMP(6) WITH TIME ZONE NOT NULL,
       o_comment        VARCHAR(79),
       o_salesperson    VARCHAR(5),
       o_ordersubstatus CHARACTER(1) CASESPECIFIC,
       o_comment_ext1   VARCHAR(79),
       o_ship_addr      VARCHAR(500),
       o_bill_addr      VARCHAR(200),
       o_alt_ship_addr  VARCHAR(500),
       o_alt_bill_addr  VARCHAR(200),
       o_item_count     INTEGER )
     PARTITION BY (COLUMN ALL BUT ((o_orderstatus, o_ordersubstatus),
                                   (o_comment, o_comment_ext1),
                        ROW(o_ship_addr, o_bill_addr) NO AUTO COMPRESS,
                        COLUMN(o_alt_ship_addr, o_alt_bill_addr)) ADD 1,
                   RANGE_N(o_ordertsz 
                    BETWEEN TIMESTAMP '2003-01-01 00:00:00.000000+00:00'
                    AND     TIMESTAMP '2009-12-31 23:59:59.999999+00:00' 
                    EACH INTERVAL '1' MONTH) ),
     UNIQUE INDEX(o_orderkey);