Defining a UDT

You define a user-defined type (UDT) using the CREATE DISTINCT TYPE statement.

For the CREATE DISTINCT TYPE statement, note that:

  1. The name of the new UDT can be a qualified or an unqualified name.
  2. The source type of the UDT is the type used by the system to internally represent the UDT. For this reason, it must be a built-in data type. Previously defined UDTs cannot be used as source types of other UDTs.

As part of a UDT definition, the system always generates cast functions to:

  • Cast from the UDT to the source type, using the standard name of the source type. For example, if you create a distinct type based on FLOAT, the cast function called DOUBLE is created.
  • Cast from the source type to the UDT.

These functions are important for the manipulation of UDTs in queries.

The function path is used to resolve any references to an unqualified type name or function, except if the type name or function is the main object of a CREATE, DROP, or COMMENT ON statement.