15.10 - ADD ROW (column_name) - 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 column partition containing the column use ROW format, if it is not already defined with ROW format.

AUTO COMPRESS
The column partition containing the column use ROW format with autocompression.
NO AUTO COMPRESS
The column partition containing the column use ROW format without autocompression.

Example: Altering a Column Partition to ROW Format for a Join Index with a Primary AMP Index

Assume this table definition:

CREATE TABLE Orders
    ( o_orderkey INTEGER NOT NULL,
      o_custkey INTEGER,
      o_orderstatus CHAR(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 CHAR(1) CASESPECIFIC,
      o_comment_ext1 VARCHAR(79),
      o_comment_ext2 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 )
  PRIMARY AMP INDEX (o_orderkey)
  PARTITION BY (
    COLUMN AUTO COMPRESS ALL BUT ( 
                     o_ordersubstatus NO AUTO COMPRESS,
                     (o_comment_ext1, o_comment_ext2) NO AUTO COMPRESS,
                     ROW(o_ship_addr, o_bill_addr) NO AUTO COMPRESS,
                     COLUMN(o_alt_ship_addr, o_alt_bill_addr) ),
  UNIQUE INDEX (o_orderkey);

Create a join index as follows:

CREATE JOIN INDEX jOrders AS
    SELECT ROWID AS rw, o_custkey, o_salesperson, o_bill_addr
      FROM Orders
  PRIMARY AMP INDEX (o_custkey)
  PARTITION BY COLUMN NO AUTO COMPRESS
    ALL BUT (o_salesperson AUTO COMPRESS);

Alter the column partition to have ROW format:

ALTER TABLE jOrders ADD ROW(o_bill_addr);

This results in a join index definition as follows:

CREATE JOIN INDEX jOrders AS
    SELECT ROWID AS rw, o_custkey, o_salesperson, o_bill_addr
      FROM Orders
  PRIMARY AMP INDEX (o_custkey)
  PARTITION BY COLUMN NO AUTO COMPRESS
    ALL BUT (o_salesperson AUTO COMPRESS, ROW(o_bill_addr));