MySQL数据类型为INT(11)而UNSIGNED INT(10)? [英] MySQL datatype INT(11) whereas UNSIGNED INT(10)?

查看:2134
本文介绍了MySQL数据类型为INT(11)而UNSIGNED INT(10)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我们在MySQL中创建 INT 的字段数据类型并且没有指定任何长度/值,那么它将自动变为 int(11)如果我们设置属性 UNSIGNED UNSIGNED ZEROFILL ,则会变为 int(10)



这个长度(1)在哪里?

解决方案

int值可以是-2147483648这些是11位数,因此默认 显示 大小为11



unsigned int不允许使用负数,因此默认情况下只需 显示 大小10



作为文档如下图所示,存储SIGNED INT和UNSIGNED INT所需的位数相同,可存储数字的范围仅仅移位:


无符号类型可用于在
列中仅允许
非负数,或者当您需要更大的
数字范围时e为专栏。对于
示例,如果INT列为UNSIGNED,则
列的范围大小为
相同,但其端点从
-2147483648和2147483647更改为0和4294967295。


http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html


in MySQL if we create a field dataType of INT and does not specify any length/values then it automatically became int(11) and if we set the attribute UNSIGNED or UNSIGNED ZEROFILL then it turns into int(10)

Where does this length(1) goes?

解决方案

int value can be -2147483648 these are 11 digits so the default display size is 11

unsigned int does not allow negative numbers so by default it need only display size 10

As the documentation below shows, the number of bits required to store SIGNED INT and UNSIGNED INT is the same, the range of storable numbers is merely shifted:

Unsigned type can be used to permit only nonnegative numbers in a column or when you need a larger upper numeric range for the column. For example, if an INT column is UNSIGNED, the size of the column's range is the same but its endpoints shift from -2147483648 and 2147483647 up to 0 and 4294967295.

http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html

这篇关于MySQL数据类型为INT(11)而UNSIGNED INT(10)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆