共识? MySQL,签名 VS 未签名主/外键

发布于 2024-09-07 01:00:57 字数 116 浏览 10 评论 0原文

我看到了一些关于每个人现在在签名与未签名键值方面所做的事情的线程。看来无符号是最佳的,因为它允许以相同的成本增加两倍的行数。签名密钥有什么好处吗?

有没有标准共识?似乎签名就是答案,因为“一直都是这样”

I have seen a couple threads about what everyone was doing now a days in regards to signed vs unsigned key values. It would seem that unsigned is optimal since it allows twice the number of rows for the same cost. Are there any benefits with signed keys?

Is there any standard consensus? Its seems like signed is the answer since "it has always been that way"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦毁影碎の 2024-09-14 01:00:57

如果列不能为负数,我更愿意将列设置为无符号。除了您提到的范围因素之外,它还使阅读表定义时更加清晰。

I prefer to set my columns as unsigned if they cannot be negative. Besides the range factor that you mentioned, it also makes it clearer when reading the table definition.

梦忆晨望 2024-09-14 01:00:57

一个有符号的 32 位 int 可以代表超过 20 亿个数字,所以我怀疑这个问题对大多数人来说没有实际意义。也就是说,当我想表明一条记录是故意孤立的时,我经常使用负数。

A signed 32-bit int can represent over 2 billion numbers so I suspect the issue is moot for most people. That said, I often use negative numbers when I want to indicate that a record is purposefully orphaned.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文