Postgresql 中文操作指南
8.12. UUID Type #
数据类型 _uuid_存储通用唯一标识符 (UUID),如 RFC 4122、ISO/IEC 9834-8:2005 及相关标准所定义的。 (有些系统称此数据类型为全局唯一标识符或 GUID。)此标识符是一个 128 位数量,由算法生成,该算法选择使任何人使用相同的算法在已知宇宙中生成相同标识符的可能性极小。因此,对于分布式系统,这些标识符比序列生成器提供更好的唯一性保证,而序列生成器只在单个数据库中是唯一的。
The data type uuid stores Universally Unique Identifiers (UUID) as defined by RFC 4122, 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.
UUID 被写成一串小写十六进制数字,由几个用连字符分隔的组组成,具体而言是一个由 8 位数字组成的组,后面是三个由 4 位数字组成的组,后面是一个由 12 位数字组成的组,总共有 32 位数字代表 128 位。此标准格式下的 UUID 示例如下:
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 还接受输入的以下备选形式:使用大写数字、用大括号括起来的标准格式、省略部分或全部连字符、在任何四位数字后面添加连字符。示例如下:
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.
有关如何在 PostgreSQL 中生成 UUID,请参见 Section 9.14。
See Section 9.14 for how to generate a UUID in PostgreSQL.