# uuid

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [cloud-data-platform-full.txt](https://docs.redpanda.com/cloud-data-platform-full.txt)

---
title: uuid
latest-operator-version: v26.2.3
latest-console-tag: v3.11.0
latest-connect-version: 4.108.0
latest-redpanda-tag: v26.2.2
docname: sql/sql-data-types/uuid
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: sql/sql-data-types/uuid.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/reference/pages/sql/sql-data-types/uuid.adoc
description: The uuid data type is a 128-bit universally unique identifier (UUID).
page-topic-type: reference
page-git-created-date: "2026-08-18"
page-git-modified-date: "2026-08-18"
---

<!-- Source: https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-data-types/uuid.md -->

The `uuid` data type represents a 128-bit universally unique identifier (UUID). Redpanda SQL exposes it to PostgreSQL clients as the `uuid` type.

Redpanda SQL surfaces a `uuid` column when it reads a UUID column from a Redpanda topic, whether from the topic’s Avro-encoded live records or from its Iceberg-committed history. See [Query Iceberg-enabled topics](https://docs.redpanda.com/cloud-data-platform/sql/query-data/query-iceberg-topics/).

An Avro field with the `uuid` logical type maps to `uuid`, regardless of whether the field is backed by `string` or `fixed`. Protobuf and JSON have no UUID type. For how record schema types translate into the Iceberg table, see [Schema types translation](https://docs.redpanda.com/cloud-data-platform/manage/iceberg/specify-iceberg-schema/#schema-types-translation).

## [](#text-representation)Text representation

Redpanda SQL renders a UUID as the 36-character canonical form: 32 hexadecimal digits in five hyphen-separated groups (`8-4-4-4-12`).

a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11

## [](#casting)Casting

The `uuid` type doesn’t cast implicitly to or from other types, and text and string functions don’t operate on `uuid` values directly. Cast a UUID explicitly:

| Cast | Result |
| --- | --- |
| id::text | The 36-character canonical form, for example a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11. |
| id::bytea | The raw 16-byte binary encoding of the UUID. |
| 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid | A uuid value parsed from text. Use this to compare against or filter on a UUID. |

When casting text to `uuid`, Redpanda SQL accepts not only the 36-character canonical form, but also any variant accepted by PostgreSQL: hex digits can be upper- or lower-case, hyphens can be omitted or placed between any four-digit groups, and the value can be wrapped in braces. An invalid input fails with `invalid input syntax for type uuid`. When casting `uuid` to text or returning it from a `SELECT`, the output is always the canonical form.

You can also cast a 16-byte `bytea` value to `uuid`.

For example, to read a UUID column as text:

```sql
SELECT id::text FROM default_redpanda_catalog=>events;
```

To filter on a UUID value, cast the text literal to `uuid`:

```sql
SELECT * FROM default_redpanda_catalog=>events
WHERE id = 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid;
```

You can also write the literal with the `uuid` keyword:

```sql
WHERE id = uuid 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'
```

## [](#generate-a-uuid)Generate a UUID

Generate a random version 4 UUID with [`gen_random_uuid()`](https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-functions/other-functions/gen-random-uuid/) or its equivalent, `uuidv4()`:

```sql
SELECT gen_random_uuid();
```