↑↓ select ↵ open ⌫ change scope Open full search

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

Wiki / Data Types / Other built-in types

uuid

universally unique identifier

Reading PostgreSQL 18.6.

PG10–20 core source inventory. Casts and operator classes show explicitly declared relationships; absent rows do not rule out coercions or indexing through other mechanisms.

Definition

universally unique identifier

uuid
Catalog name
pg_catalog.uuid
Type OID
2950
Type kind
Base type
Declared length
16 bytes
Storage strategy
plain
Input function
uuid_in
Output function
uuid_out

English manual

Read the complete manual section

Read the source definition

8.12. UUID Type

The data type uuid stores Universally Unique Identifiers (UUID) as defined by RFC 9562, ISO/IEC 9834-8:2005, and related standards. (Some systems refer to this data type as a globally unique identifier, or GUID, instead.) This identifier is a 128-bit quantity that is generated by an algorithm chosen to make it very unlikely that the same identifier will be generated by anyone else in the known universe using the same algorithm. Therefore, for distributed systems, these identifiers provide a better uniqueness guarantee than sequence generators, which are only unique within a single database.

RFC 9562 defines 8 different UUID versions. Each version has specific requirements for generating new UUID values, and each version provides distinct benefits and drawbacks. PostgreSQL provides native support for generating UUIDs using the UUIDv4 and UUIDv7 algorithms. Alternatively, UUID values can be generated outside of the database using any algorithm. The data type uuid can be used to store any UUID, regardless of the origin and the UUID version.

A UUID is written as a sequence of lower-case hexadecimal digits, in several groups separated by hyphens, specifically a group of 8 digits followed by three groups of 4 digits followed by a group of 12 digits, for a total of 32 digits representing the 128 bits. An example of a UUID in this standard form is:

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

PostgreSQL also accepts the following alternative forms for input: use of upper-case digits, the standard format surrounded by braces, omitting some or all hyphens, adding a hyphen after any group of four digits. Examples are:

A0EEBC99-9C0B-4EF8-BB6D-6BB9BD380A11
{a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11}
a0eebc999c0b4ef8bb6d6bb9bd380a11
a0ee-bc99-9c0b-4ef8-bb6d-6bb9-bd38-0a11
{a0eebc99-9c0b4ef8-bb6d6bb9-bd380a11}

Output is always in the standard form.

See Section 9.14 for how to generate a UUID in PostgreSQL.

Catalog attributes

Source bootstrap values for this build. See pg_type for field meanings. Header defaults are included; build-dependent constants remain symbolic. This is not a live-server measurement.

oid
2950
descr
UUID
typacl
_null_
typlen
16
typelem
0
typname
uuid
typsend
uuid_send
typtype
b
typalign
c
typarray
0
typbyval
f
typdelim
','
typinput
uuid_in
typmodin
-
typndims
0
typowner
POSTGRES
typrelid
0
typmodout
-
typoutput
uuid_out
typtypmod
-1
typanalyze
-
typdefault
_null_
typnotnull
f
typreceive
uuid_recv
typstorage
p
typbasetype
0
typcategory
U
typcollation
0
typisdefined
t
typnamespace
pg_catalog
typsubscript
-
typdefaultbin
_null_
array_type_oid
2951
typispreferred
f
array_type_name
_uuid

Operator overloads 6

Each operand signature is a separate overload. Catalog implementation functions and result types belong to the same source build.

OperatorLeft operandRight operandResultMeaningImplementation
=uuiduuidboolequaluuid_eq
<>uuiduuidboolnot equaluuid_ne
<uuiduuidboolless thanuuid_lt
>uuiduuidboolgreater thanuuid_gt
<=uuiduuidboolless than or equaluuid_le
>=uuiduuidboolgreater than or equaluuid_ge

Operator classes 5

Operator classes whose declared input type matches this type. Polymorphic classes, casts and expression indexes can provide additional index paths; this list is not an exhaustive yes/no index-support test.

ClassIndex methodInput typeFamilyDefaultStorage type
uuid_opsbtreeuuidbtree/uuid_opsYesSame as input
uuid_opshashuuidhash/uuid_opsYesSame as input
uuid_minmax_opsbrinuuidbrin/uuid_minmax_opsYesuuid
uuid_minmax_multi_opsbrinuuidbrin/uuid_minmax_multi_opsNouuid
uuid_bloom_opsbrinuuidbrin/uuid_bloom_opsNouuid

Version comparison

PostgreSQL 17.11 → 18.6. Source build identifiers and prose are excluded from attribute changes.

No catalog or structured attribute changes between these samples.

The documentation also differs between these builds; inspect the versioned manual definitions.

Documentation and source

Build
18.6 · https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2
Fingerprint
555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f

Related entries

All Data Types · Download this version as JSON · The first recorded sample does not establish when a type was introduced.