Mysql的BigInt(20),Int(20)以及Bigint(32)有区别吗? 您所在的位置:网站首页 bigint20能放多少个字 Mysql的BigInt(20),Int(20)以及Bigint(32)有区别吗?

Mysql的BigInt(20),Int(20)以及Bigint(32)有区别吗?

2024-07-12 15:23| 来源: 网络整理| 查看: 265

The number in parentheses in a type declaration is display width , which is unrelated to the range of values that can be stored in a data type. Just because you can declare Int(20) does not mean you can store values up to 10^20 in it:

[...] This optional display width may be used by applications to display integer values having a width less than the width specified for the column by left-padding them with spaces. ...

The display width does not constrain the range of values that can be stored in the column, nor the number of digits that are displayed for values having a width exceeding that specified for the column. For example, a column specified as SMALLINT(3) has the usual SMALLINT range of -32768 to 32767, and values outside the range allowed by three characters are displayed using more than three characters.

For a list of the maximum and minimum values that can be stored in each MySQL datatype, see here .

 

Mysql的数字类型(1B,2B,3B,4B,8B都有)

一个INT,占4个字节,跟JAVA中的int一样,即使是有符号也能表达21亿 这么大的数据。 所以平时绝大多数情况,包括大型网站的UID,都用不了这么大的数据,好友关系表可能会超过,关系表可以考虑用BIGINT。还有就是平时时间戳需要用BIGINT。总之,不要轻易用上BIGINT,完全是浪费!



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有