User-defined data types

A user-defined data type is a data type that is defined using a CREATE TYPE statement.

The following types of user-defined data type are supported:

Distinct types

A distinct type is a user-defined data type that is based on existing built-in Db2 data types.

A distinct type is internally the same as a built-in data type, but Db2 treats them as a separate and incompatible type for semantic purposes. Defining your own distinct type ensures that only functions that are explicitly defined on a distinct type can be applied to its instances.

For more information, see Distinct types.

Array types

A user-defined array type is a data type that is defined as an array of elements. A user-defined array type can be either an ordinary array or associative array.

A user-defined ordinary array type has a maximum cardinality, which is specified on the CREATE TYPE (array) statement. A user-defined associative array has a maximum cardinality of 2 billion.

An array value is a structure that contains an ordered collection of elements. All elements of an array value must have the same data type. The cardinality of the array is equal to the number of elements in the array.

For more information, see Array types and values.