15.00 - Recommended Null Handling Technique for UDT, ARRAY, VARRAY, Geospatial, and Period Columns - Teradata Database

Teradata Database SQL Data Definition Language Detailed Topics

prodname
Teradata Database
vrm_release
15.00
category
Programming Reference
featnum
B035-1184-015K

Recommended Null Handling Technique for UDT, ARRAY, VARRAY, Geospatial, and Period Columns

If you intend to support null attributes for structured UDT, ARRAY, VARRAY, Geospatial, or Period columns, or if a UDT, Geospatial, or Period column has a map ordering routine that can return nulls, then any CREATE TABLE or ALTER TABLE requests that specify that type should specify the NOT NULL attribute for that UDT, ARRAY, VARRAY, Geospatial, or Period column.

This is because if nulls are permitted in the column and either the map ordering routine or the system‑generated observer method for the type can return nulls, then a situation exists that is somewhat analogous to the situation in which queries are executed against a column attributed as NOT CASESPECIFIC. In this situation, for some queries, the results returned for identical requests can be non‑deterministic, varying 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 follow this recommendation, then it is possible for the following cases to be treated equally.

  • A column null.
  • A structured type that contains null attributes and whose map or observer routine returns nulls.
  • In other words, 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);