gpt4 book ai didi

MySQL 主/外键大小?

转载 作者:可可西里 更新时间:2023-11-01 06:36:33 29 4
gpt4 key购买 nike

我似乎看到很多人在他们的 MySQL 模式中任意分配大尺寸的主/外键字段,例如 INT(11) 甚至 WordPress 使用的 BIGINT(20)。

如果我错了,请纠正我,但即使是 INT(4) 也支持高达 40 亿以上的(无符号)值。将其更改为 INT(5) 并且您允许的值高达千万亿,这超出了您的需要,除非您可能正在 NASA/Google 存储地理数据,我相信我们大多数人都没有。

人们使用如此大的主键有什么原因吗?对我来说似乎是一种浪费......

最佳答案

The size is neither bits nor bytes. It's just the display width, that is used when the field has ZEROFILL specified.

INT[(M)] [UNSIGNED] [ZEROFILL] A normal-size integer. The signed range is -2147483648 to 2147483647. The unsigned range is 0 to 4294967295.

参见 this explanation .

关于MySQL 主/外键大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2841147/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com