System.Guid 中的 guid
根据 MSDN,他们将 System.Guid.NewGuid() 描述为..
The chance that the value of the new Guid will be all zeros or equal to any other Guid is very **low**
将 Customer 表的 customerID 设置为“uniqueidentifier”并使用 System.Guid.NewGuid() 生成唯一 id 是一个坏主意吗?我如何确保该方法只生成唯一的 ID?
As per MSDN, they describe System.Guid.NewGuid() as ..
The chance that the value of the new Guid will be all zeros or equal to any other Guid is very **low**
Will it be a bad idea to set customerID of Customer table to "uniqueidentifier" and generate the unique id using the System.Guid.NewGuid() ? How can I assure the method will generate only unique IDs ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除非您有充分的理由使用 Guid 作为 ID,否则我建议不要使用 Guid 作为键。指南会占用数据库中的大量空间,并且在常见情况下没有任何好处。另外,它们不能很好地处理索引。
为什么不将 CustomerID 设置为整数并将其设置为在插入新记录时自动生成其值?
Unless you have very good reasons to use Guid as ID, I would recommend against using Guid as key. Guids take a lot of space in a database, and provide no benefit in common scenarios. Plus they do not play well with indexes.
Why don't you set the CustomerID as an integer and set it to auto-generate its value when you insert a new record?