我看到这两个首字母缩写被抛出,我想知道是否有任何区别之间的GUID和UUID?


当前回答

SQL Server中的GUID和PostgreSQL中的UUID之间的一个区别是字母大小写;SQL Server输出上,PostgreSQL输出下。

十六进制值“a”到“f”输出为小写字符,输入时不区分大小写。- rfc4122 #第三节

其他回答

GUID在不一定是128位值(与UUID相同)的领域有着长期的使用。例如,RSS规范将guid定义为您所选择的任何字符串,只要它是唯一的,并带有“isPermalink”属性,以指定您正在使用的值只是返回到被联合的项目的永久链接。

简单的答案是:**没有区别,它们是一样的东西。

2020-08-20 Update: While GUIDs (as used by Microsoft) and UUIDs (as defined by RFC4122) look similar and serve similar purposes, there are subtle-but-occasionally-important differences. Specifically, some Microsoft GUID docs allow GUIDs to contain any hex digit in any position, while RFC4122 requires certain values for the version and variant fields. Also, [per that same link], GUIDs should be all-upper case, whereas UUIDs should be "output as lower case characters and are case insensitive on input". This can lead to incompatibilities between code libraries (such as this).

(原答案如下)


把它们当作一个16字节(128位)的值,用作唯一的值。在微软语言中,它们被称为guid,但在不使用微软语言时称为uuid。

甚至UUID规范的作者和微软都声称它们是同义词:

From the introduction to IETF RFC 4122 "A Universally Unique IDentifier (UUID) URN Namespace": "a Uniform Resource Name namespace for UUIDs (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDentifier)." From the ITU-T Recommendation X.667, ISO/IEC 9834-8:2004 International Standard: "UUIDs are also known as Globally Unique Identifiers (GUIDs), but this term is not used in this Recommendation." And Microsoft even claims a GUID is specified by the UUID RFC: "In Microsoft Windows programming and in Windows operating systems, a globally unique identifier (GUID), as specified in [RFC4122], is ... The term universally unique identifier (UUID) is sometimes used in Windows protocol specifications as a synonym for GUID."

但正确答案取决于问题中提到“UUID”时的意思…

第一部分取决于询问者在说“UUID”时的想法。

微软的声明暗示所有uuid都是guid。但是所有的guid都是真实的uuid吗?也就是说,所有uuid的集合只是所有guid集合的适当子集,还是完全相同的集合?

查看RFC 4122的详细信息,uuid有四种不同的“变体”。这主要是因为在创建UUID规范时将这些规范结合在一起之前就使用了这样的16字节标识符。在RFC 4122的4.1.1节中,UUID的四种变体是:

预留,网络计算系统向后兼容 RFC 4122中指定的变体(其中有五个子变体,称为“版本”) 保留,微软公司向后兼容 保留以后的定义。

根据RFC 4122,所有UUID变体都是“真正的UUID”,那么所有guid都是真正的UUID。对于字面上的问题“GUID和UUID之间有什么区别吗”,对于RFC 4122 UUID,答案肯定是没有区别:没有区别(但受制于下面的第二部分)。

But not all GUIDs are variant 2 UUIDs (e.g. Microsoft COM has GUIDs which are variant 3 UUIDs). If the question was "is there any difference between GUID and variant 2 UUIDs", then the answer would be yes -- they can be different. Someone asking the question probably doesn't know about variants and they might be only thinking of variant 2 UUIDs when they say the word "UUID" (e.g. they vaguely know of the MAC address+time and the random number algorithms forms of UUID, which are both versions of variant 2). In which case, the answer is yes different.

因此,答案在一定程度上取决于提问者在说“UUID”这个词时的想法。他们是指变体2 UUID(因为这是他们知道的唯一变体)还是所有UUID ?

第二部分取决于使用哪个规范作为UUID的定义。

If you think that was confusing, read the ITU-T X.667 ISO/IEC 9834-8:2004 which is supposed to be aligned and fully technically compatible with RFC 4122. It has an extra sentence in Clause 11.2 that says, "All UUIDs conforming to this Recommendation | International Standard shall have variant bits with bit 7 of octet 7 set to 1 and bit 6 of octet 7 set to 0". Which means that only variant 2 UUID conform to that Standard (those two bit values mean variant 2). If that is true, then not all GUIDs are conforming ITU-T/ISO/IEC UUIDs, because conformant ITU-T/ISO/IEC UUIDs can only be variant 2 values.

因此,真正的答案还取决于问题所询问的UUID规范。假设我们清楚地谈论的是所有uuid,而不仅仅是变体2 uuid: GUID和IETF的uuid之间没有区别,但是GUID和符合ITU-T/ISO/IEC的uuid之间有区别!

二进制编码可能不同

当以二进制编码时(与人类可读的文本格式相反),GUID可以存储在具有如下四个不同字段的结构中。该格式与[UUID standard] 8仅在前3个字段的字节顺序上有所不同。

Bits  Bytes Name   Endianness  Endianness
                   (GUID)      RFC 4122

32    4     Data1  Native      Big
16    2     Data2  Native      Big
16    2     Data3  Native      Big
64    8     Data4  Big         Big

SQL Server中的GUID和PostgreSQL中的UUID之间的一个区别是字母大小写;SQL Server输出上,PostgreSQL输出下。

十六进制值“a”到“f”输出为小写字符,输入时不区分大小写。- rfc4122 #第三节

不是真的。GUID更以微软为中心,而UUID的使用更广泛(例如,在urn: UUID: urn方案和CORBA中)。

GUID是微软对UUID标准的实现。

维基百科:

术语GUID通常指的是微软通用唯一标识符(UUID)标准的实现。

同一篇维基百科文章的最新引用:

RFC 4122本身指出uuid“也称为guid”。所有这些都表明,“GUID”,虽然最初指的是微软使用的UUID的一个变体,但已经成为UUID的一个简单的替代名称……