]> begriffs open source - ai-pg/blob - full-docs/txt/datatype-uuid.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / datatype-uuid.txt
1
2 8.12. UUID Type #
3
4    The data type uuid stores Universally Unique Identifiers (UUID) as
5    defined by RFC 9562, ISO/IEC 9834-8:2005, and related standards. (Some
6    systems refer to this data type as a globally unique identifier, or
7    GUID, instead.) This identifier is a 128-bit quantity that is generated
8    by an algorithm chosen to make it very unlikely that the same
9    identifier will be generated by anyone else in the known universe using
10    the same algorithm. Therefore, for distributed systems, these
11    identifiers provide a better uniqueness guarantee than sequence
12    generators, which are only unique within a single database.
13
14    RFC 9562 defines 8 different UUID versions. Each version has specific
15    requirements for generating new UUID values, and each version provides
16    distinct benefits and drawbacks. PostgreSQL provides native support for
17    generating UUIDs using the UUIDv4 and UUIDv7 algorithms. Alternatively,
18    UUID values can be generated outside of the database using any
19    algorithm. The data type uuid can be used to store any UUID, regardless
20    of the origin and the UUID version.
21
22    A UUID is written as a sequence of lower-case hexadecimal digits, in
23    several groups separated by hyphens, specifically a group of 8 digits
24    followed by three groups of 4 digits followed by a group of 12 digits,
25    for a total of 32 digits representing the 128 bits. An example of a
26    UUID in this standard form is:
27 a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11
28
29    PostgreSQL also accepts the following alternative forms for input: use
30    of upper-case digits, the standard format surrounded by braces,
31    omitting some or all hyphens, adding a hyphen after any group of four
32    digits. Examples are:
33 A0EEBC99-9C0B-4EF8-BB6D-6BB9BD380A11
34 {a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11}
35 a0eebc999c0b4ef8bb6d6bb9bd380a11
36 a0ee-bc99-9c0b-4ef8-bb6d-6bb9-bd38-0a11
37 {a0eebc99-9c0b4ef8-bb6d6bb9-bd380a11}
38
39    Output is always in the standard form.
40
41    See Section 9.14 for how to generate a UUID in PostgreSQL.