Are Guids guaranteed to be unique?

后端 未结 3 806
后悔当初
后悔当初 2021-01-21 08:31

I\'m using Guids as primary keys in my database and was wondering if it is ever possible that a duplicate Guid might be generated. Are Guids guaranteed to be unique?

3条回答
  •  日久生厌
    2021-01-21 08:50

    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.

提交回复
热议问题