# gen_random_uuid (uuidv4)

> 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: gen_random_uuid (uuidv4)
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-functions/other-functions/gen-random-uuid
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: sql/sql-functions/other-functions/gen-random-uuid.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/reference/pages/sql/sql-functions/other-functions/gen-random-uuid.adoc
description: The gen_random_uuid() and uuidv4() functions return a random version 4 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-functions/other-functions/gen-random-uuid.md -->

The [`gen_random_uuid()`](https://www.postgresql.org/docs/current/functions-uuid.html) function returns a random version 4 UUID as a [`uuid`](https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-data-types/uuid/) value. `uuidv4()` is equivalent: both take no arguments and return a random version 4 UUID.

These functions are volatile: they return a new value on each call, so a query that calls one once per row produces a distinct UUID for each row.

## [](#syntax)Syntax

The syntax for these functions is:

```sql
gen_random_uuid()
uuidv4()
```

Each function takes no arguments and returns a value of type [`uuid`](https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-data-types/uuid/).

## [](#examples)Examples

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

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

The function returns a random UUID in the 36-character canonical form. For example:

           gen\_random\_uuid
--------------------------------------
 a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11

`uuidv4()` returns the same kind of value:

```sql
SELECT uuidv4();
```