---
title: "DB2: How to create user-defined data type"
description: "User-defined data types are like user-defined functions to create customized data types . https://srinimf.com/2015/11/06/how-concat-operator-and-concat-function-are-identical/. UDD Type Example. For e..."
url: https://srinimf.com/2012/05/27/db2-user-defined-data-type/
date: 2012-05-27
modified: 2026-10-10
author: "Srini"
categories: ["DB2"]
tags: ["db2", "UDT"]
type: post
lang: en
---

# DB2: How to create user-defined data type

[User-defined data types](https://srinimf.com/2022/12/24/these-are-user-defined-data-types-in-db2/) are like user-defined functions [to create](https://srinimf.com/2020/07/25/db2-user-defined-function-syntax-to-create-drop/) customized [data types](https://srinimf.com/2015/10/13/db2-large-object-data-types-advantage-of-lobs/).

Related[CONCAT Operator ‘||’ Vs. CONCAT Function – Are They Identical?](https://srinimf.com/2015/11/06/how-concat-operator-and-concat-function-are-identical/)

## UDD Type Example

For example, [CREATE DISTINCT TYPE](https://srinimf.com/2012/04/24/db2-why-cast-function-needed-2-of-2/) 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](https://srinimf.com/2015/09/24/db2-sql-procedure-basics-for-mainframe-programmers-1-of-2/);
```

The basic difference is , we can create a structure with mix [of db2](https://srinimf.com/2015/06/05/sweet-spots-of-db2-v11-with-hadoop/) existing types and UDTs.

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

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2012%2F05%2F27%2Fdb2-user-defined-data-type%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2026%2F02%2Fcropped-logo.png%3Ffit%3D96%252C96%26ssl%3D1&description=DB2%3A%20How%20to%20create%20user-defined%20data%20type)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2012/05/27/db2-user-defined-data-type/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2012/05/27/db2-user-defined-data-type/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2012/05/27/db2-user-defined-data-type/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2012/05/27/db2-user-defined-data-type/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20DB2%3A%20How%20to%20create%20user-defined%20data%20type&body=https%3A%2F%2Fsrinimf.com%2F2012%2F05%2F27%2Fdb2-user-defined-data-type%2F&share=email)
-

### Like this:

Like Loading…
