↑↓ 选择↵ 打开⌫ 切换范围完整搜索

PG.CENTER 连接 PostgreSQL 文档、百科与生态知识。由 Pigsty 维护。

Wiki / 数据类型

uuid

universally unique identifier

当前阅读 PG 18·选择有来源记录的版本

此版本暂无所选语言的定义,以下显示原始英文内容。

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
aliases
未知
casts
未知
coverage
source inventory; exact declared input types for operator classes
manual documentation
dedicated family chapter
manual path
datatype-uuid.html
ranges
未知
signature
uuid

版本定义 PG 18

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

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

operator classes

map[opcdefault:t opcfamily:btree/uuid_ops opcintype:uuid opckeytype:0 opcmethod:btree opcname:uuid_ops opcnamespace:pg_catalog opcowner:POSTGRES], map[opcdefault:t opcfamily:hash/uuid_ops opcintype:uuid opckeytype:0 opcmethod:hash opcname:uuid_ops opcnamespace:pg_catalog opcowner:POSTGRES], map[opcdefault:t opcfamily:brin/uuid_minmax_ops opcintype:uuid opckeytype:uuid opcmethod:brin opcname:uuid_minmax_ops opcnamespace:pg_catalog opcowner:POSTGRES], map[opcdefault:f opcfamily:brin/uuid_minmax_multi_ops opcintype:uuid opckeytype:uuid opcmethod:brin opcname:uuid_minmax_multi_ops opcnamespace:pg_catalog opcowner:POSTGRES], map[opcdefault:f opcfamily:brin/uuid_bloom_ops opcintype:uuid opckeytype:uuid opcmethod:brin opcname:uuid_bloom_ops opcnamespace:pg_catalog opcowner:POSTGRES]

operators

map[descr:equal oid:2972 oprcanhash:t oprcanmerge:t oprcode:uuid_eq oprcom:=(uuid,uuid) oprjoin:eqjoinsel oprkind:b oprleft:uuid oprname:= oprnamespace:pg_catalog oprnegate:<>(uuid,uuid) oprowner:POSTGRES oprrest:eqsel oprresult:bool oprright:uuid], map[descr:not equal oid:2973 oprcanhash:f oprcanmerge:f oprcode:uuid_ne oprcom:<>(uuid,uuid) oprjoin:neqjoinsel oprkind:b oprleft:uuid oprname:<> oprnamespace:pg_catalog oprnegate:=(uuid,uuid) oprowner:POSTGRES oprrest:neqsel oprresult:bool oprright:uuid], map[descr:less than oid:2974 oprcanhash:f oprcanmerge:f oprcode:uuid_lt oprcom:>(uuid,uuid) oprjoin:scalarltjoinsel oprkind:b oprleft:uuid oprname:< oprnamespace:pg_catalog oprnegate:>=(uuid,uuid) oprowner:POSTGRES oprrest:scalarltsel oprresult:bool oprright:uuid], map[descr:greater than oid:2975 oprcanhash:f oprcanmerge:f oprcode:uuid_gt oprcom:<(uuid,uuid) oprjoin:scalargtjoinsel oprkind:b oprleft:uuid oprname:> oprnamespace:pg_catalog oprnegate:<=(uuid,uuid) oprowner:POSTGRES oprrest:scalargtsel oprresult:bool oprright:uuid], map[descr:less than or equal oid:2976 oprcanhash:f oprcanmerge:f oprcode:uuid_le oprcom:>=(uuid,uuid) oprjoin:scalarlejoinsel oprkind:b oprleft:uuid oprname:<= oprnamespace:pg_catalog oprnegate:>(uuid,uuid) oprowner:POSTGRES oprrest:scalarlesel oprresult:bool oprright:uuid], map[descr:greater than or equal oid:2977 oprcanhash:f oprcanmerge:f oprcode:uuid_ge oprcom:<=(uuid,uuid) oprjoin:scalargejoinsel oprkind:b oprleft:uuid oprname:>= oprnamespace:pg_catalog oprnegate:<(uuid,uuid) oprowner:POSTGRES oprrest:scalargesel oprresult:bool oprright:uuid]

来源引用

完整定义与证据 JSON

定义来源

center · PostgreSQL 18 · 555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f

正文语言: en · 555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f