---
title: generate_uuidv7() | Tiger Data Docs
description: Generate a version 7 UUID based on current time
---

Since [2.23.0](https://github.com/timescale/timescaledb/releases/tag/2.23.0)

Generate a UUIDv7 object based on the current time.

The UUID contains a UNIX timestamp split into millisecond and sub-millisecond parts, followed by random bits.

You can use this function to generate a time-ordered series of UUIDs suitable for use in a time-partitioned column in TimescaleDB.

![UUIDv7 structure with microsecond-precision timestamp](/docs/_astro/uuidv7-structure-microseconds.BBrmloq3.svg)

## Samples

- **Generate a UUIDv7 object based on the current time**

  ```
  SELECT generate_uuidv7();
             generate_uuidv7
  --------------------------------------
   019913ce-f124-7835-96c7-a2df691caa98
  ```

- **Insert a generated UUIDv7 object**

  ```
  INSERT INTO alerts VALUES (generate_uuidv7(), 'high CPU');
  ```

## Returns

| Column            | Type | Description                                                 |
| ----------------- | ---- | ----------------------------------------------------------- |
| `generate_uuidv7` | UUID | A UUIDv7 object based on the current time with random bits. |
