根据官方文档描述,int(M)中的M表示数据显示的宽度,与实际存储的长度无关。

1、也就是int(3)和int(11)能够存储的数据是一样的,都是从-21474836482147483647(或者0-4294967295)。

2、int(M)只有联合zerofill参数才能有意义,否则int(3)和int(11)没有任何区别。

下面用实例来证明上述两句话:

1、创建测试表,具有int(3)、int(11)、int三个字段

create table test_int(id int(3) unsigned not null,uid int(11) unsigned not null,uuid int unsigned not null );

下面插入int无符号能够存储的最大值:

insert into test_int values(4294967295,4294967295,4294967295);

(product)root@localhost [a]> select * from test_int;+------------+------------+------------+| id         | uid        | uuid       |+------------+------------+------------+| 4294967295 | 4294967295 | 4294967295 |+------------+------------+------------+1 row in set (0.00 sec)

【结论1】通过上述实验,对于没有加上zerofill参数的int、int(3)、int(11)无论在存储上还是在显示上都毫无区别。

2、创建测试表,具有int(3)、int(11)、int三个字段同时加上zerofill参数

(product)root@localhost [a]> create table test_int1(id int(3) unsigned zerofill not null,uid int(11) unsigned zerofill not null,uuid int unsigned zerofill not null );
Query OK, 0 rows affected (0.14 sec)(product)root@localhost [a]> insert into test_int1 values(4294967295,4294967295,4294967295);
Query OK, 1 row affected (0.03 sec)(product)root@localhost [a]> insert into test_int1 values(1,4294967295,110000);
Query OK, 1 row affected (0.00 sec)(product)root@localhost [a]> select * from test_int1;
+------------+-------------+------------+
| id         | uid         | uuid       |
+------------+-------------+------------+
| 4294967295 | 04294967295 | 4294967295 |
|        001 | 04294967295 | 0000110000 |
+------------+-------------+------------+
2 rows in set (0.00 sec)

【结论2】通过上述实验,对于加上zerofill参数的int、int(3)、int(11),不足M宽度的,用0补充,否则不影响显示。

转载于:https://www.cnblogs.com/mysql-dba/p/5197736.html

INT(M)表示什么意思?相关推荐

  1. Thinking In C++中文版

    下载 第1章  对象的演化 计算机革命起源于一台机器,程序设计语言也源于一台机器. 然而计算机并不仅仅是一台机器,它是心智放大器和另一种有表述能力的媒体.这一点 使它不很像机器,而更像我们大脑的一部分 ...

  2. c语言long int表示范围_C语言编程第9讲——这些C语言整数类型的知识点你掌握了吗...

    1.char其实是一种整数类型 在C语言中,字符使用整数来表示. 例如下面的代码: #include int main(){ char letter = '2'; printf("Lette ...

  3. C++ 笔记(26)— 主函数 main(int argc, char *argv[]) 参数说明

    带形参的 main 函数,如 int main( int argc, char* argv[], char **env ) 是 UNIX .Linux 以及 Mac OS 操作系统中 C/C++ 的 ...

  4. java 无法取消引用_Java的新手,并出现错误“无法取消引用int” - java

    我是java的新手,并且已经从事了一段时间,但是仍然收到错误消息:无法取消引用int.我看到了几个类似的问题,但仍然无法弄清自己的情况. 这是完整的代码: package inclass; class ...

  5. python 把int类型转bytes以及把bytes 转int 类型(使用方法to_bytes ,from_byte, struct)

    把int类型转bytes 方法1 使用方法to_bytes to_bytes 方法里面有3个参数 , 第一个数是指定要转换的bytes占多少个字节 第二个是byteorder 是指定大端或者是小端 的 ...

  6. TypeError: sequence item 1: expected str instance, int found

    报错具体内容如下: 这里 是使用re.sub() 函数的时候 ,里面的第二个参数必须是string 类型, 我这里使用int 类型所以就报错了 处理方法就是把 int 类型数据转成string 类型的 ...

  7. ValueError: invalid literal for int() with base 10: “ ”

    出现这个错误 :ValueError: invalid literal for int() with base 10: ''  " 或者: ValueError: invalid liter ...

  8. TypeError: ord() expected string of length 1, but int found

    错误如下 ord 里面要求的是一个string 的字符, 这里使用了int  ,所以修改了print(ord("1")) 转ASCII 的时候需要注意了,

  9. BigDecimal 转换为int 或者其他类型

    我列举了转换的方法 BigDecimal HALF_UP = new BigDecimal("-12.44").setScale(1, RoundingMode.HALF_UP); ...

  10. public static final int REMIN_REQUEST_CODE = 0x911 自己的大致理解

    public static final int REMIN_REQUEST_CODE = 0x911; 自己理解为 一个静态常量,也就一个标识,自己目前主要在2个地方常用到 OnActivityRes ...

最新文章

  1. 用静态工厂方法代替构造器
  2. Python科学计算:Pandas
  3. 嵌入式开发常用工具软件
  4. 网站搭建从零开始(五) WordPress的安装
  5. java 可变参数方法_Java方法中的参数太多,第7部分:可变状态
  6. 文件夹 计算机无法使用,电脑文件夹提示被使用无法删除怎么办
  7. dotnetnuke|dnn 内网实现自动登录
  8. (转)Spring4.2.5+Hibernate4.3.11组合开发
  9. 使用命令将logcat中的内容输出到文本文件中
  10. mysql 类似 oracle connect by_mysql实现层级查询,相似oracle里的connect by prior
  11. ios 更多 Url Schemes
  12. php开发电脑i56200u,Intel Core i5-6200U性能跑分和评测 | ZMMOO
  13. Python获取列表list中的非零数据、第一个非零元素、最后一个非零元素
  14. 被老婆赶出家门,男子嚎啕大哭:击垮一个成年人,一次失业就够了
  15. vue动态增加商品属性
  16. android x86启动卡死,[更新]Android-x86启动成功,但是还有点小问题。
  17. 如何在家赚钱,盘点5个方法,让你足不出户也能挣钱
  18. Mac安装、配置Maven
  19. C++ dpi,px,cm,mm换算心得,以及以a4纸计算为例,其它大家各自换算
  20. HTML的meta标签

热门文章

  1. Hyperledger Fabric 1.0 实战开发系列 第二课 Fabric环境搭建
  2. dji大疆机器人冬令营_2019RoboMaster高中生机器人冬令营火热进行中
  3. python编程环境要求_python公开课|我们需要优秀Python编程环境的要求居然是这些...
  4. mysql root密码重置
  5. performance and scalability
  6. 用java设计一个二叉树类的结构,二叉树的基本结构以及java实现
  7. 多参量最优化matlab,fmincon函数优化多个参数
  8. python中subprocess_Python中subprocess学习
  9. go hello world第一个程序
  10. Codeforces Round #208 (Div. 2)D. Dima and Hares