Recommended Null Handling Technique For UDT Columns - Advanced SQL Engine - Teradata Database

SQL Data Definition Language Detailed Topics

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-24
dita:mapPath
jpx1556733107962.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1184
lifecycle
previous
Product Category
Teradata Vantage™

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);