GUID 100%是唯一的吗?

它会在多个线程中保持唯一吗?


当前回答

从http://www.guidgenerator.com/online-guid-generator.aspx

What is a GUID? GUID (or UUID) is an acronym for 'Globally Unique Identifier' (or 'Universally Unique Identifier'). It is a 128-bit integer number used to identify resources. The term GUID is generally used by developers working with Microsoft technologies, while UUID is used everywhere else. How unique is a GUID? 128-bits is big enough and the generation algorithm is unique enough that if 1,000,000,000 GUIDs per second were generated for 1 year the probability of a duplicate would be only 50%. Or if every human on Earth generated 600,000,000 GUIDs there would only be a 50% probability of a duplicate.

其他回答

从http://www.guidgenerator.com/online-guid-generator.aspx

What is a GUID? GUID (or UUID) is an acronym for 'Globally Unique Identifier' (or 'Universally Unique Identifier'). It is a 128-bit integer number used to identify resources. The term GUID is generally used by developers working with Microsoft technologies, while UUID is used everywhere else. How unique is a GUID? 128-bits is big enough and the generation algorithm is unique enough that if 1,000,000,000 GUIDs per second were generated for 1 year the probability of a duplicate would be only 50%. Or if every human on Earth generated 600,000,000 GUIDs there would only be a 50% probability of a duplicate.

Eric Lippert写了一系列关于guid的非常有趣的文章。

There are on the order 230 personal computers in the world (and of course lots of hand-held devices or non-PC computing devices that have more or less the same levels of computing power, but lets ignore those). Let's assume that we put all those PCs in the world to the task of generating GUIDs; if each one can generate, say, 220 GUIDs per second then after only about 272 seconds -- one hundred and fifty trillion years -- you'll have a very high chance of generating a collision with your specific GUID. And the odds of collision get pretty good after only thirty trillion years.

GUID指南,第一部分 GUID指南,第二部分 GUID指南,第三部分

在更广泛的意义上,这被称为“生日问题”或“生日悖论”。维基百科有一个很好的概述: 维基百科-生日问题

粗略地说,池大小的平方根是一个粗略的近似值,即您可以期望有50%的重复机会。这篇文章包含了一个关于池大小和各种概率的概率表,包括2^128的一行。所以对于1%的碰撞概率,你可以随机选择2.6*10^18个128位数字。50%的概率需要2.2*10^19次选择,而根号(2^128)是1.8*10^19次选择。

当然,这只是一个真正随机过程的理想情况。正如其他人所提到的,很多事情都取决于随机方面——生成器和种子有多好?如果有一些硬件支持来帮助这个过程,那就太好了,这将更加防弹,除非任何东西都可能被欺骗或虚拟化。我怀疑这可能是MAC地址/时间戳不再被合并的原因。

GUID代表全局唯一标识符

简而言之: (线索就在名字里)

详细: guid被设计为唯一的;它们是使用基于计算机时钟和计算机本身的随机方法计算的,如果你在同一毫秒内在同一台机器上创建多个guid,它们可能是匹配的,但对于几乎所有的正常操作,它们应该被认为是唯一的。

我经历了一个重复的GUID。

我使用的是Neat收据桌面扫描仪,它自带专有数据库软件。该软件有一个同步到云的功能,我总是在同步时得到一个错误。浏览一下日志,你会发现这句话非常棒:

"errors":[{"code":1,"message":"creator_guid: is already . 了”、“guid”:“c83e5734 d77a - 4 - b09 b8c1 - 9623 cac7b167”}]}

我有点难以置信,但可以肯定的是,当我找到进入本地网络数据库的方法并删除包含该GUID的记录时,错误就停止了。

所以用轶事证据来回答你的问题,没有。副本是可能的。但它发生的原因很可能不是由于偶然,而是由于标准的做法在某种程度上没有得到遵守。(我只是没有那么幸运)然而,我不能肯定。这不是我的软件。

他们的客户支持非常有礼貌和乐于助人,但他们以前肯定从未遇到过这个问题,因为在与他们电话交谈3个多小时后,他们没有找到解决方案。(总之,Neat给我留下了深刻的印象,这个小故障虽然令人沮丧,但并没有改变我对他们产品的看法。)