Nullable Columns Are Valid for Unique Indexes - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

While columns defined with PRIMARY KEY or UNIQUE constraints not only cannot be null, but must also be explicitly defined as NOT NULL, nullable columns are valid for UPI and NUPI column definitions. This is not good database design practice. Permit nullable columns in index definitions only under extraordinary conditions.

These semantics demand that nulls in unique index columns must be treated as if they are equal even though SQL nulls only represent an absence of value, which means they can neither be equated nor compared in any other way. All null primary index rows hash to the same AMP, so even a UPI can produce row distribution skew if you allow it to be null. See Inconsistencies in How SQL Treats Nulls for a description of other inconsistencies.

UNIQUE or UNIQUE PRIMARY Index Format Result
Single column That column can have only one row with a null value.
Multiple columns The table can have at most one row in which all values are identical.