DB2: How to create user-defined data type

User-defined data types are like user-defined functions to create customized data types.

UDD Type Example

For example, CREATE DISTINCT TYPE AUDIO AS BLOB(1M);

So now the “audio” becomes a new data-type. If we talk about user defined data types, there are 2 types.

Distinct Type

In this case, the only user-defined type is customized based on an existing type

Structured Type

CREATE TYPE PERSON_DET AS (NAME CHAR(20),
AGE INT,
ADDRESS ADDRESS_T,
INSTANTIABLE
REF USING VARCAHR(13) FOR BIT DATA
MODE DB2 SQL;

The basic difference is , we can create a structure with mix of db2 existing types and UDTs.

The usage for UDTs we can see in the Banking domain.  

Discover more from Srinimf

Subscribe now to keep reading and get access to the full archive.

Continue reading