15.10 - Example: Dropping and Adding Partition Ranges - 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 ALTER TABLE request modifies the tables orders and orders_cp created in Table Definitions for Examples. The outcome of the requests are identical to the table alterations performed in later ALTER TABLE requests in this example, but using different syntax.

The request is valid if there are no rows with values for o_orderdate between January 1, 1992 (DATE ‘1992-01-01’) and December 31, 1992 (DATE ‘1992-12-31’).

     ALTER TABLE orders 
     MODIFY
       DROP RANGE BETWEEN DATE '1992-01-01' 
                  AND     DATE '1992-12-31'
       ADD  RANGE BETWEEN  DATE '1999-01-01' 
                  AND      DATE '2000-12-31' 
                  EACH INTERVAL '1' MONTH;

The following request modifies the partitioning for the column-partitioned table orders_cp.

     ALTER TABLE orders_cp 
     MODIFY
       DROP RANGE BETWEEN DATE '1992-01-01' 
                  AND     DATE '1992-12-31'
       ADD  RANGE BETWEEN  DATE '1999-01-01' 
                  AND      DATE '2000-12-31' 
                  EACH INTERVAL '1' MONTH;

The following ALTER TABLE request modifies the table created in Table Definitions for Examples. The result is equivalent to the outcome of other requests in this example set using different syntax, and is valid if there are no rows with values for o_orderdate between January 1 1992 (DATE ‘1992-01-01’) and December 31 1992 (DATE ‘1992-12-31’).

     ALTER TABLE orders 
     MODIFY
       DROP RANGE WHERE PARTITION BETWEEN 1 
                                  AND    12
       ADD RANGE BETWEEN DATE '1999-01-01' 
                 AND     DATE '2000-12-31' 
                 EACH INTERVAL '1' MONTH;

The following request modifies the partitioning for the column-partitioned table orders_cp.

     ALTER TABLE orders_cp 
     MODIFY
       DROP RANGE BETWEEN DATE '1992-01-01' 
                  AND     DATE '1992-12-31'
       ADD  RANGE BETWEEN  DATE '1999-01-01' 
                  AND      DATE '2000-12-31' 
                  EACH INTERVAL '1' MONTH;

The following ALTER TABLE request modifies the table created in Table Definitions for Examples. The result is equivalent to the outcome of other requests in this example set and is valid if there are no rows with values for o_orderdate between January 1 1992 (DATE ‘1992-01-01’) and December 31 1992 (DATE ‘1992-12-31’).

     ALTER TABLE orders 
     MODIFY
       DROP RANGE WHERE Orders.PARTITION IN (1,2,3,4,5,6,7,8,9,10,11,12)
       ADD  RANGE BETWEEN DATE '1999-01-01' 
                  AND     DATE '2000-12-31' 
                  EACH INTERVAL '1' MONTH;

The following request modifies the partitioning for the column-partitioned table orders_cp.

     ALTER TABLE orders_cp 
     MODIFY
       DROP RANGE BETWEEN DATE '1992-01-01' 
                  AND     DATE '1992-12-31'
                  EACH INTERVAL '1' MONTH
       ADD  RANGE BETWEEN  DATE '1999-01-01' 
                  AND      DATE '2000-12-31' 
                  EACH INTERVAL '1' MONTH;