指导是否被保证是唯一的? [英] Are Guids guaranteed to be unique?

查看:84
本文介绍了指导是否被保证是唯一的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据库中使用Guid作为主键,并且想知道是否有可能生成重复的Guid.指导是否被保证是唯一的?

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?

推荐答案

虽然不能保证每个生成的GUID都是唯一的,但总计 唯一键的数量(2128或3.4×1038)太大,以至于 两次产生相同数字的可能性很小.

While each generated GUID is not guaranteed to be unique, the total number of unique keys (2128 or 3.4×1038) is so large that the probability of the same number being generated twice is very small.

您可以在这里.

一种可能的解决方案,以避免重复的指导(如果您仍然想要的话)是使用

A possible solution to avoid duplicate guids (if you still want one) is to use the UNIQUE constraint.

这篇关于指导是否被保证是唯一的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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