8.12. UUID Type
8.12.UUID类型
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数据类型存储RFC 4122,ISO/IEC 9834-8:2005和相关标准定义的通用唯一标识符(UUID)。(某些系统将这种数据类型称为全局唯一标识符,或称为GUID。)此标识符是128位的数量,该值是由一种算法生成的,以确保其他人使用相同的算法时,不会生成相同的值。因此,对于分布式系统,这些标识符提供了比仅在单个数据库中唯一的序列生成器更好的唯一性保证。
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:
UUID是由小写的十六进制数字序列组成的,有-分隔每组,由一组8位,然后是三组4位,再是一组12位,总共32位组成,用以代表128位。 此标准格式的UUID的示例是:
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:
PostgreSQL还接受以下替代输入形式:使用大写字母,用大括号括起来的标准格式,省略一些或所有连字符,在任何四位数组之后添加连字符。 例如:
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.
输出总是标准格式。
参考第9.14节以了解在PostgreSQL中如何生成UUID。