mysql:int 类型的最大值问题

标签 mysql

我使用 mysql 创建了两个字段 text(varchar), number(int)。但我不确定我应该为 varchar()int()varchar() 设置什么大小,我在这里检查过:http://dev.mysql.com/doc/refman/5.0/en/char.html ,并且知道如果我输入 varchar(4),这意味着:最多可以容纳 4 个字符。但是对于int(4),我这里查了:http://dev.mysql.com/doc/refman/5.0/en/integer-types.html,据说是:Maximum Value:(Signed/Unsigned)(2147483647/4294967295)

问题:

对于int(4),它是如何得到这个值2147483647/4294967295的?如果我输入 int(8),值会是多少?

最佳答案

See the MySQL Numeric Type Documentation .这些事情都有据可查。

The range for a signed INT is [-2147483648, 2147483647].

Note that in the case of INT(x), x is the "display width" and has nothing to do with the range or space requirements:

MySQL supports an extension for optionally specifying the display width of integer data types in parentheses following the base keyword for the type. For example, INT(4) specifies an INT with a display width of four digits ... display width does not constrain [or expand] the range of values that can be stored in the column.

Mysql int(11) number out of range

关于mysql:int 类型的最大值问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18310742/

相关文章:

mysql - 不是那么简单的 SQL 查询

javascript - 文本区域输出到页面的特殊格式创建与某些数据的链接

mysql - 获取 mysql 中存储的 Proc Schema 名称

php - 检查结果是否为整数/varchar/等。 SQL执行期间?

php - MySQL 查询 : Select. ..Not In () in php

MySQL 合并 2 个具有相同 Id 值的表

PHP select 不返回值

php - 在单独的数据透视表中按计数对行进行排序

python - 如何在Django中将对象从 "default"DB复制到另一个具有相同结构的DB

c++ - 在 C++ 和 Mysql 中,从 std::sqlString 到 char const* 的转换无效