Define a unique secondary index (USI) for the table.
- Optional name for the index.
- For information about naming database objects, see Teradata Vantage™ - SQL Fundamentals, B035-1141.
- Column set whose values are to be used as the basis for a secondary index.
- Columns in the list cannot have any of the following data types: BLOB, CLOB, Period, XML, Geospatial, JSON, or DATASET.
- If you specify more than one column name, the index is created on the combined values of each column named. A maximum of 64 columns can be specified for an index, and a maximum of 32 secondary indexes can be created for one table.
WITH LOAD IDENTITY
Records the RowLoadID for the index created on a load isolated table.
You can specify this option for indexes created on load isolated tables.
- Does not record RowLoadID with the ROWIDs in a NUSI. The base row, using the qualified ROWID from the index row must be used to determine the committed property. This index may be simpler to maintain but read operations are more expensive than the regular NUSI based option, limiting the usability of index.
Example: Multilevel-Partitioned NUPI With a USI Defined on the Primary Index
The following example creates a two-level PPI table using the RANGE_N function as the basis for both partitioning expressions. Because neither partitioning column is a component of the primary index, that index must be defined as a NUPI. To enforce uniqueness, a USI is defined on o_orderkey.
CREATE TABLE orders ( o_orderkey INTEGER NOT NULL, o_custkey INTEGER, o_orderstatus CHARACTER(1) CASESPECIFIC, o_totalprice DECIMAL(13,2) NOT NULL, o_orderdate DATE FORMAT 'yyyy-mm-dd' NOT NULL, o_orderpriority CHARACTER(21), o_clerk CHARACTER(16), o_shippriority INTEGER, o_comment VARCHAR(79)) PRIMARY INDEX (o_orderkey) PARTITION BY (RANGE_N(o_custkey BETWEEN 0 AND 49999 EACH 100), RANGE_N(o_orderdate BETWEEN DATE '2000-01-01' AND DATE '2006-12-31' EACH INTERVAL '1' MONTH)) UNIQUE INDEX (o_orderkey);