15.10 - Example: Adding a Single-Column Partition - 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

The following example adds a single-column partition using system-determined COLUMN format and autocompression to the orders table.

     ALTER TABLE orders 
     ADD (o_salesperson VARCHAR(5));

The following equivalent request performs the same actions to alter the table.

     ALTER TABLE orders 
     ADD o_salesperson VARCHAR(5);

Both requests alter the orders table to have the following definition with o_salesperson set to NULL in each row of the table.

     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) )
     PARTITION BY (COLUMN ADD 4,
     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);