MySQL: bigint Vs int(MySQL:bigint 与 int)
问题描述
我一直在使用 int(10) 并且刚刚注意到 Wordpress 使用 bigint(20) - 使用 bigint(20) 和 int(10) 进行 id 自动递增有什么不同?我应该为 id 列使用哪一个?
I have been using int(10) and just noticed that Wordpress uses bigint(20) - What is different to use bigint(20) and int(10) for id auto increment? Which one should I use for id column?
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
对比
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
谢谢.
推荐答案
区别纯粹在于可以存储的最大值(我相信 bigint(20) 为 18,446,744,073,709,551,615,int(10) 为 4,294,967,295),根据 MySQL 数值类型的详细信息手册页.
The difference is purely in the maximum value which can be stored (18,446,744,073,709,551,615 for the bigint(20) and 4,294,967,295 for the int(10), I believe), as per the details on the MySQL Numeric Types manual page.
顺便说一句,除非您使用 ZEROFILL,否则 (20) 和 (10) 的使用在很大程度上是无关紧要的.(即:它实际上并没有改变所存储数字的大小——这完全取决于类型.)
Incidentally, the use of (20) and (10) is largely irrelevant unless you're using ZEROFILL. (i.e.: It doesn't actually change the size of the number stored - that's all down to the type.)
但是,实际上应该注意的是,除非您是真正活跃的博主,否则您不太可能很快达到这些限制中的任何一个.
However, in practical terms it should be noted that you're not likely to hit either of these limits any time soon, unless you're a really active blogger.
这篇关于MySQL:bigint 与 int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MySQL:bigint 与 int


基础教程推荐
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 带更新的 sqlite CTE 2022-01-01