MySQL:bigint 与 int

MySQL: bigint Vs int(MySQL:bigint 与 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)
SQL/MySQL: split a quantity value into multiple rows by date(SQL/MySQL:按日期将数量值拆分为多行)