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


- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- SQL 临时表问题 2022-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 更改自动增量起始编号? 2021-01-01