---
title: "gen_random_uuid()"
url: "https://docs.yugabyte.com/stable/api/ysql/exprs/func_gen_random_uuid/"
---

# gen_random_uuid()

Generate a UUID.

## Synopsis

Use the `gen_random_uuid()` function to generate a UUID.

This function returns a version 4 (random) UUID. This is the most commonly used type of UUID and is appropriate for most applications.

The [uuid-ossp](/stable/additional-features/pg-extensions/extension-uuid-ossp "uuid-ossp") and [pgcrypto](/stable/additional-features/pg-extensions/extension-pgcrypto "pgcrypto") modules provide additional functions that implement other standard algorithms for generating UUIDs.

## Example

You can generate a UUID and check its type using the `pg_typeof` function.

```sql
select gen_random_uuid(), pg_typeof(gen_random_uuid());
```

You will get an output similar to:

```caddyfile
           gen_random_uuid            | pg_typeof
--------------------------------------+-----------
 15684ea8-0505-4fb3-b3f7-1be2f253e0ed | uuid
```

## Learn more

- [uuid-ossp](/stable/additional-features/pg-extensions/extension-uuid-ossp "uuid-ossp") module
