select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

FUNCTIONS / UUID FUNCTIONS

Generates a version 7 (time-ordered) UUID.

Signatures & examples

uuidv7 ( [ shift interval ] ) → uuid
Generates a version 7 (time-ordered) UUID. The timestamp is computed using UNIX timestamp with millisecond precision + sub-millisecond timestamp + random. The optional parameter shift will shift the computed timestamp by the given interval. Infinite interval values are not accepted. The shifted timestamp must fall within the range supported by UUID version 7's 48-bit millisecond timestamp field: from 1970-01-01 00:00:00 UTC to approximately year 10889. An error is raised if the resulting timestamp is outside this range.
uuidv7() → 019535d9-3df7-79fb-b466-fa907fa17f9e
Version history 1
  1. PG 17 → 18added

Definition snapshot: 2026-09-14T13:14:25.684213+00:00@99e6866c · English manual source