15.10 - PRIMARY AMP - 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

Add a primary AMP index.

Rows are hash-distributed to AMPs for a column-partitioned table or join index. Column partition values are ordered on each AMP by an internal partition number and a row hash for a column-partitioned table or join index.

If a PRIMARY AMP clause is specified, you must specify a PARTITION BY clause that includes a column-partitioning level, either in the PRIMARY AMP clause or by itself in the index list.

INDEX
Optionally, the INDEX keyword can be specified with AMP for readability.
index_name
Name of the primary AMP index. For information about naming database objects, see SQL Fundamentals, B035-1141.
(index_column_name)
The primary AMP index columns. For a composite primary index, index_column_name indicates a comma-separated list of all the index columns in parenthesis. You cannot specify the begin or end columns of a derived period column in a primary index.

You cannot alter a table to have a row-level security constraint column as a component of its primary index.
You cannot define a primary index on a column defined with the JSON data type.

Example: Join Index with a Primary AMP Index and Column Partitioning

This example assumes the following table has been created:

CREATE TABLE t1 (a INT, b INT, c INT, d INT) PRIMARY INDEX (a);

The following CREATE JOIN INDEX statements are equivalent:

CREATE JOIN INDEX jt1_1 AS SELECT ROWID AS rw, a, b FROM t1 WHERE a<10
  PRIMARY AMP (a) PARTITION BY COLUMN (rw NO AUTO COMPRESS, ROW(a,b));
CREATE JOIN INDEX jt1_1 AS SELECT ROWID AS rw, a, b FROM t1 WHERE a<10
  PRIMARY AMP INDEX (a) PARTITION BY COLUMN (rw NO AUTO COMPRESS, ROW(a,b));

Example: Join Index with a Primary Index and Partitioning by Row and Column

This example assumes the following table has been created:

CREATE TABLE t1 (a INT, b INT, c INT, d INT) PRIMARY INDEX (a);

This example shows a CREATE JOIN INDEX statement with a primary index and partitioned by row and column:

CREATE JOIN INDEX jt1_4 AS SELECT ROWID rw, a, b, d
  FROM t1
  PRIMARY INDEX (a) PARTITION BY (RANGE_N(b BETWEEN 1 AND 1000 EACH 1), COLUMN);