Is a GUID unique 100% of the time?

Is a GUID unique 100% of the time?

Will it stay unique over multiple threads?


While each generated GUID is not guaranteed to be unique, the total number of unique keys (2^128 or 3.4×10^38) is so large that the probability of the same number being generated twice is very small. For example, consider the observable universe, which contains about 5×10^22 stars; every star could then have 6.8×10^15 universally unique GUIDs.

From Wikipedia.


These are some good articles on how a GUID is made (for .NET) and how you could get the same guid in the right situation.

http://ericlippert.com/2012/04/24/guid-guide-part-one/

http://ericlippert.com/2012/04/30/guid-guide-part-two/

http://ericlippert.com/2012/05/07/guid-guide-part-three/


The simple answer is yes.

Raymond Chen wrote a great article on GUIDs and why substrings of GUIDs are not guaranteed unique. The article goes in to some depth as to the way GUIDs are generated and the data they use to ensure uniqueness, which should go to some length in explaining why they are :-)


If you are scared of the same GUID values then put two of them next to each other.

Guid.NewGuid().ToString() + Guid.NewGuid().ToString();

If you are too paranoid then put three.

链接地址: http://www.djcxy.com/p/16256.html

上一篇: GUID / UUID数据库密钥的优缺点

下一篇: 100%的时间内GUID是唯一的吗?