DISTINCT data types
A DISTINCT type is a data type that is derived from a source type (called the base type).
- A built-in type
- An existing DISTINCT type
- An existing named ROW type
- An existing opaque type
A DISTINCT type inherits from its source type the length and alignment on the disk. A DISTINCT type thus makes efficient use of the preexisting functionality of the database server.
When you create a DISTINCT data type, the database server automatically creates two explicit casts: one cast from the DISTINCT type to its source type and one cast from the source type to the DISTINCT type. A DISTINCT type based on a built-in source type does not inherit the built-in casts that are provided for the built-in type. A DISTINCT type does inherit, however, any user-defined casts that have been defined on the source type.
A DISTINCT type cannot be compared directly to its source type. To compare the two types, you must first explicitly cast one type to the other.
- The CREATE DISTINCT TYPE statement adds a DISTINCT type to the database.
- The DROP TYPE statement removes a previously defined DISTINCT type from the database.
For more information about the SQL statements mentioned above, see the Informix® Guide to SQL: Syntax. For information about casting DISTINCT data types, see Casts for distinct types. For examples that show how to create and register cast functions for a DISTINCT type, see the Informix® Database Design and Implementation Guide.
Size specifications in declarations of DISTINCT types whose base types are built-in character types can be affected by the SQL_LOGICAL_CHAR feature that is described in the section Logical Character Semantics in Character Type Declarations.