问题描述
我一直在使用 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!