Movatterモバイル変換


[0]ホーム

URL:


September 25, 2025: PostgreSQL 18 Released!
Supported Versions:Current (18) /17 /16 /15 /14 /13
Development Versions:devel
Unsupported versions:12 /11 /10 /9.6 /9.5 /9.4 /9.3 /9.2 /9.1 /9.0 /8.4 /8.3
8.12. UUID Type
Prev UpChapter 8. Data TypesHome Next

8.12. UUID Type#

The data typeuuid stores Universally Unique Identifiers (UUID) as defined byRFC 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 typeuuid 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}a0eebc999c0b4ef8bb6d6bb9bd380a11a0ee-bc99-9c0b-4ef8-bb6d-6bb9-bd38-0a11{a0eebc99-9c0b4ef8-bb6d6bb9-bd380a11}

Output is always in the standard form.

SeeSection 9.14 for how to generate a UUID inPostgreSQL.


Prev Up Next
8.11. Text Search Types Home 8.13. XML Type

Submit correction

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please usethis form to report a documentation issue.


[8]ページ先頭

©2009-2025 Movatter.jp