使用UUID的唯一ID生成真的很独特吗? [英] Is unique id generation using UUID really unique?

查看:326
本文介绍了使用UUID的唯一ID生成真的很独特吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望生成唯一ID,就像java中的自动增量一样。所以以前我使用当前纳秒秒,但我最终得到了冲突,因为两个数据在相同的纳秒时间内出现..
UUID是否解决了上述问题?

I want generate unique ID just like auto increment in java . So previously i used current nano seconds but i end up with clash since two data comes with in same nano seconds .. Does UUID solves the above problem ?

注意::在我的项目中,我甚至可以每分钟获得10000行记录,我会将这些记录与UIDS一起转储到表中。可能会出现这样的情况:我会停止我的产品并在一段时间后重新启动它....所以在那种情况下,UUID类如何澄清先前生成的UID(我存储在DB中)将要创建的新UID(还要转储到DB中)?

Note :: In my project i can even get 10000 rows of records for each and every minute and I will dump those records along with UIDS in to table .And there may be a situation where i would stop my product and restart it after some time ....So during that situation how could UUID class clarifies the previously generated Uids(which i stored in DB) with the new one going to created(Yet to be dumped in DB) ?

推荐答案

虽然UUID不是保证是唯一的,但重复的可能性非常低。请参阅随机UUID重复概率

While the UUIDs are not guaranteed to be unique, the probability of a duplicate is extremely low. See Random UUID probability of duplicates.

对于您的应用程序,使用UUID是有意义的,但您可能想要处理极其罕见的情况,以防万一。

For your application, it makes sense to use the UUID, but you may want to deal with the extremely rare condition, just in case.

这篇关于使用UUID的唯一ID生成真的很独特吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆