问题描述
我正在 SQL Server 2000 中开发一个数据库,该数据库为每个使用它所关联的应用程序的用户使用一个 GUID.不知何故,两个用户最终获得了相同的 GUID.我知道微软使用一种算法来生成一个随机 GUID,它导致碰撞的可能性极低,但碰撞仍然可能发生吗?
I'm working on a database in SQL Server 2000 that uses a GUID for each user that uses the app it's tied to. Somehow, two users ended up with the same GUID. I know that microsoft uses an algorithm to generate a random GUID that has an extremely low chance of causing collisons, but is a collision still possible?
推荐答案
基本上没有.我认为有人搞砸了你的数据库.根据您使用的版本 GUID,该值要么是唯一的(对于版本 1 GUID 之类的东西),要么是唯一且不可预测的(对于版本 4 GUID 之类的东西).SQL Server 对其 NEWID() 函数的实现似乎使用 128 位随机数,因此您不会发生冲突.
Basically, no. I think someone went mucking with your database. Depending on the version GUID you're using the value is either unique (for things like version 1 GUIDs), or both unique and unpredictable (for things like version 4 GUIDs). SQL Server's implementation for their NEWID() function appears to use a 128-bit random number, so you're not going to get a collision.
对于 1% 的碰撞几率,您需要生成大约 2,600,000,000,000,000,000 个 GUID.
For a 1% chance of collision, you'd need to generate about 2,600,000,000,000,000,000 GUIDs.
这篇关于GUID 冲突是否可能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!