16.20 - Recommended Null Handling Technique For UDT Columns - Teradata Database - Teradata Vantage NewSQL Engine

Teradata Vantage™ SQL Data Definition Language Detailed Topics

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Release Date
March 2019
Content Type
Programming Reference
Publication ID
B035-1184-162K
Language
English (United States)

If you intend to support null attributes or if you write a map ordering routine that can return nulls, then any CREATE TABLE or ALTER TABLE statements that specify that type should specify the NOT NULL attribute for that UDT column.

If nulls are permitted in the column and either the map ordering routine or the system-generated observer method for the UDT can return nulls, the results returned for identical requests can vary from query to query.

The ordering routine for a UDT determines whether or not column values are equal and also determines the collation order for sort operations.

If you do not specify the NOT NULL attribute for UDT columns, then the following objects may be treated equally.

  • A column null.
  • A structured type that contains null attributes and whose map or observer routine returns nulls.

Sometimes a column null is returned in the result set and other times the non-null structured type that contains null attributes is returned in the result set.

The following simple example indicates how you should specify the NOT NULL attribute for UDT columns in a table definition.

     CREATE TABLE udtTable (
       id         INTEGER,
       udtColumn  myStructUdtWithNullAttributes NOT NULL);