http://everythingmysql.ning.com/profiles/blogs/data-type-confusion-what-is-an

Over and over I see customers that don't understand what int(11) really means. Their confusion is understandable. Many know what defining a char(10) means (a fixed-sized character string that allows up to 10 characters). However, ints are different.

First of all, there are 5 types of integer. They are all fixed size.

Type # of bytes
tinyint 1
smallint 2
mediumint 3
int 4
bigint 8

As you can see from the chart, an int is always 4 bytes. That can store signed numbers from -2 billion to +2 billion (and unsigned numbers 0 to 4B). So, what does it mean if you declare an int(5)? It does not restrict the number of digits to 5... It may actually do nothing! The (5) part is a display width. It's only used if you use UNSIGNED and ZEROFILL with an integer type. Then the display of those numbers will be zero-padded on the left to 5 digits if they contain less than 5 digits. Example:


CREATE TABLE `foo` (
`bar` int(5) unsigned zerofill DEFAULT NULL
)

 SELECT * FROM foo;
+---------+
| bar |
+---------+
| 00042 |
| 00101 |
| 9876543 |
+---------+

Data type confusion: what is an int(11)?的更多相关文章

  1. java 反射 报错:Attempt to get java.lang.Integer field "..." with illegal data type conversion to int

    类: Integer id; 反射时: Field f = User.class.getDeclaredField("id"); f.setAccessible(true); in ...

  2. MySql and Oracle Data Type Mappings

    the default settings used by SQL Developer to convert data types from MySQL to Oracle. SQL Developer ...

  3. 1月21日 Reference Data Type 数据类型,算法基础说明,二分搜索算法。(课程内容)

    Reference Datat Types 引用参考数据类型 -> 组合数据类型 Array, Hash和程序员自定义的复合资料类型 组合数据的修改: 组合数据类型的变量,不是直接存值,而是存一 ...

  4. MySQL int(11)及int(M)解析

    默认创建int类型的字段,SHOW CREATE TABLE table_name或DESC table_name常常可以看到其默认情况为int(11). 这个int(M)很多时候都会被误解为最大范围 ...

  5. JAVA 1.2(原生数据类型 Primitive Data Type)

    1. Java的数据类型分为2类 >> 原生数据类型(primitive data type) >> 引用数据类型(reference data type) 3. 常量和变量 ...

  6. salesforce 零基础开发入门学习(四)多表关联下的SOQL以及表字段Data type详解

    建立好的数据表在数据库中查看有很多方式,本人目前采用以下两种方式查看数据表. 1.采用schema Builder查看表结构以及多表之间的关联关系,可以登录后点击setup在左侧搜索框输入schema ...

  7. XML Data Type Methods(一)

    XML Data Type Methods(一) /*XML Data Type Methods: 1.The query('XQuery') method retrieves(vt.检索,重新得到) ...

  8. int(11)最大长度是多少,MySQL中varchar最大长度是多少(转)

    int(11)最大长度是多少,MySQL中varchar最大长度是多少? int(11)最大长度是多少? 在SQL语句中int代表你要创建字段的类型,int代表整型,11代表字段的长度. 这个11代表 ...

  9. mysql 理解 int(11)

    1.这里的int(11) 与int的大小和存储字节,没有一毛钱关系,int的存储字节是4个字节,最大值为 65536*65536 = 40多亿,对于有符号的int,是20多亿.2.那么这里的(11) ...

随机推荐

  1. 迷你MVVM框架 avalonjs 实现上的几个难点

    经过两个星期的性能优化,avalon终于实现在一个页面绑定达到上万个的时候不卡顿的目标(angular的限制是2000).现在稍作休息,总结一下avalon遇到的一些难题. 首先是如何监控的问题.所有 ...

  2. ASP.NET MVC SSO单点登录设计与实现

    实验环境配置 HOST文件配置如下: 127.0.0.1 app.com127.0.0.1 sso.com IIS配置如下: 应用程序池采用.Net Framework 4.0 注意IIS绑定的域名, ...

  3. 递归算法经典实例小结(C#实现)

     一 .递归算法简介 在数学与计算机科学中,递归是指在函数的定义中使用函数自身的方法. 递归算法是一种直接或者间接地调用自身算法的过程.在计算机编写程序中,递归算法对解决一大类问题是十分有效的,它往往 ...

  4. 解决记录日志导致VS2013缓慢的问题

    最近VS2013启动时.编译时.显示项目属性速度狂慢,遇到项目多的,显示项目属性时甚至VS挂掉. 把所有的VS插件卸载.甚至重装VS也不见效果. 用ProcessMonitor发现VS一直在Defau ...

  5. java中集合类中Collection接口中的List接口的常用方法熟悉

    1:集合类,在java语言中的java.util包提供了一些集合类,这些集合类又被称作容器. 2:区别集合类和数组.(1)数组的长度是固定的,集合的长度是可变的.(2)数组是用来存放基本数据类型的,集 ...

  6. NodeJS POST Request Over JSON-RPC

    1.npm install art-template2.npm  install request3.在app.js中加入以下代码转html: var template = require('art-t ...

  7. Android之登录那点事

    随着互联网的高速发展,一个应用为了保护用户的隐私,通常会通过设置用户名+密码的验证方式保证用户隐私的相对安全,我知道一般网站的登录验证,通常会设置一个二维码,通过验证二维码,防止恶意软件通过机械程序, ...

  8. Android搜索框效果

    转载:http://blog.csdn.net/walker02/article/details/7917392 需求:项目中的有关搜索的地方,加上清空文字的功能,目的是为了增加用户体验,使用户删除文 ...

  9. JS+CSS3实现带预览图幻灯片效果

    这个案例学习起来还有点吃力,目前还没有独自自己写出来过,贴出来以免忘记. 慕课网该课程原地址:http://www.imooc.com/learn/412 源码: <!DOCTYPE html& ...

  10. 为什么要学习Linux

    作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! 本篇修改自我在知乎上回答的问题,为什么要学习 Linux? 我最开始用Linux是 ...