小结:
0、int(4) + ZEROFILL 实现3-->0003,但可以存储12345;
1、ZEROFILL 在MySQL 8.0.17中被移除,可以通过LPAD实现补0;

https://dev.mysql.com/doc/refman/8.0/en/integer-types.html

MySQL 8.0 Reference Manual  /  ...  /  Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT

11.2.1 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT

MySQL supports the SQL standard integer types INTEGER (or INT) and SMALLINT. As an extension to the standard, MySQL also supports the integer types TINYINTMEDIUMINT, and BIGINT. The following table shows the required storage and range for each integer type.

Table 11.1 Required Storage and Range for Integer Types Supported by MySQL

Type Storage (Bytes) Minimum Value Signed Minimum Value Unsigned Maximum Value Signed Maximum Value Unsigned
TINYINT 1 -128 0 127 255
SMALLINT 2 -32768 0 32767 65535
MEDIUMINT 3 -8388608 0 8388607 16777215
INT 4 -2147483648 0 2147483647 4294967295
BIGINT 8 -263 0 263-1 264-1

 
 
 
 
 
 
https://dev.mysql.com/doc/refman/8.0/en/numeric-type-overview.html
 

11.2.5 Numeric Type Attributes

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. 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. (That is, this width is present in the metadata returned with result sets. Whether it is used is up to the application.)

The display width does not constrain the range of values that can be stored in the column. Nor does it prevent values wider than the column display width from being displayed correctly. For example, a column specified asSMALLINT(3) has the usual SMALLINT range of -32768 to 32767, and values outside the range permitted by three digits are displayed in full using more than three digits.

When used in conjunction with the optional (nonstandard) ZEROFILL attribute, the default padding of spaces is replaced with zeros. For example, for a column declared as INT(4) ZEROFILL, a value of 5 is retrieved as 0005.

Note

The ZEROFILL attribute is ignored for columns involved in expressions or UNION queries.

If you store values larger than the display width in an integer column that has the ZEROFILLattribute, you may experience problems when MySQL generates temporary tables for some complicated joins. In these cases, MySQL assumes that the data values fit within the column display width.

As of MySQL 8.0.17, the ZEROFILL attribute is deprecated for numeric data types, as is the display width attribute for integer data types. Support for ZEROFILL and display widths for integer data types will be removed in a future MySQL version. Consider using an alternative means of producing the effect of these attributes. For example, applications could use the LPAD() function to zero-pad numbers up to the desired width, or they could store the formatted numbers in CHAR columns.

int 4 bytes的更多相关文章

  1. Python入门篇-基础数据类型之整型(int),字符串(str),字节(bytes),列表(list)和切片(slice)

    Python入门篇-基础数据类型之整型(int),字符串(str),字节(bytes),列表(list)和切片(slice) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Py ...

  2. int[] convert byte[]

    private void button_Click(object sender, RoutedEventArgs e) { byte[] bytes = this.ConvertIntArrayToB ...

  3. Python基本数据类型之int

    一.int的范围 2.7: 32位:-2^31~2^31-1 64位:-2^63~2^63-1 3.5: 在3.5中init长度理论上是无限的 二.python内存机制 在一般情况下当变量被赋值后,内 ...

  4. byte和hexstring,int,string等的转换类

    public class HexConversion { /** * 16进制数的字符串转字节数组(16进制转字节数组) * * @param hexString * 16进制字符串 * @retur ...

  5. class int

    class int(object): """ int(x=0) -> integer int(x, base=10) -> integer Convert a ...

  6. C++: byte 和 int 的相互转化

    原文链接:http://blog.csdn.net/puttytree/article/details/7825709 NumberUtil.h // // NumberUtil.h // MinaC ...

  7. Java 字节数组类型(byte[])与int类型互转

    代码如下: public class CommonUtils { //高位在前,低位在后 public static byte[] int2bytes(int num){ byte[] result ...

  8. QT下int与QByteArray的转换

    int转QByteArray QByteArray intToByte(int i) { QByteArray abyte0; abyte0.resize(4); abyte0[0] = (uchar ...

  9. Java中int类型和tyte[]之间转换及byte[]合并

    JAVA基于位移的 int类型和tyte[]之间转换 [java] view plaincopy /** * 基于位移的int转化成byte[] * @param int number * @retu ...

随机推荐

  1. HTML5手机页面里面如何把长按复制避免

    在写HTML5手机页面的时候,有时候会写到一些标签是需要用户长按然后放开的 但是微信里面长按就会出现复制,大大影响了用户体验,那么如何可以避免呢? 我也是最近写到这样的页面,总结了一部分,大家可以作为 ...

  2. 2018年末--积极拥抱h5.转载 大前端时代来临,我们何去何从?

    1.大前端时代是什么? 大前端时代是WEB统一的时代,利用html5或者6甚至7,不但可以开发传统的网站,做炫酷的网页动态效果,更可以采用BS架构应用程序.开发手机端web应用.移动端Native应用 ...

  3. pandas DataFrame(1)

    之前介绍了numpy的二维数组,但是numpy二维数组有一些局限性,比如,它数组里所有的值的类型必须相同,不能某一列是数值型,某一列是字符串型,这样会导致无法使用 mean() , std() 等方法 ...

  4. Android Launcher分析和修改12——Widget列表信息收集

    很久没写Launcher分析的文章,最近实在太忙.今天七夕本来是想陪女朋友逛街 ,碰巧打台风呆在家里,就继续写一篇文章.今天主要是讲一下Launcher里面的Widget列表,这方面信息比较多,今天重 ...

  5. Thinkphp 关联模型和试图模型区别

    关联模型主要在多表操作时使用,比如 user表,user_role表,role表 user_role字段:uid,rid,它作为中间表,负责将user和role之间的,1对1,1对多,多对多的关系进行 ...

  6. 一起了解下Centos中‘vim配置’有多强大?

    在linux的系统上安装vim编辑器后,发现vim的页面设置还是不太习惯,没有显示的行号,也没有自动的缩进,页面的背景也不是很好看,但是vim编辑器是可以进行配置的,我们可以打造属于自己的vim风格. ...

  7. Turning off “Language Service Disabled” error message in VS2017

    We are getting the following "Error" message in our MVC web application in Visual studio 2 ...

  8. Git错误:error: The following untracked working tree files would be overwritten by merge:

    [andy@localhost weixin_robot]$ git pull Updating d652d1c..fa05549 error: The following untracked wor ...

  9. SQLSVR 之 EXISTS

    来个实例看看 CREATE TABLE #temp( id BIGINT, name VARCHAR(max), age INT ) CREATE TABLE #tempmain( id BIGINT ...

  10. python网络编程之UDP方式传输数据

    UDP --- 用户数据报协议(User Datagram Protocol),是一个无连接的简单的面向数据报的运输层协议. UDP不提供可靠性,它只是把应用程序传给IP层的数据报发送出去,但是并不能 ...