int 4 bytes
小结:
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
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 TINYINT
, MEDIUMINT
, 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
|
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
.
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 ZEROFILL
attribute, 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的更多相关文章
- Python入门篇-基础数据类型之整型(int),字符串(str),字节(bytes),列表(list)和切片(slice)
Python入门篇-基础数据类型之整型(int),字符串(str),字节(bytes),列表(list)和切片(slice) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Py ...
- int[] convert byte[]
private void button_Click(object sender, RoutedEventArgs e) { byte[] bytes = this.ConvertIntArrayToB ...
- Python基本数据类型之int
一.int的范围 2.7: 32位:-2^31~2^31-1 64位:-2^63~2^63-1 3.5: 在3.5中init长度理论上是无限的 二.python内存机制 在一般情况下当变量被赋值后,内 ...
- byte和hexstring,int,string等的转换类
public class HexConversion { /** * 16进制数的字符串转字节数组(16进制转字节数组) * * @param hexString * 16进制字符串 * @retur ...
- class int
class int(object): """ int(x=0) -> integer int(x, base=10) -> integer Convert a ...
- C++: byte 和 int 的相互转化
原文链接:http://blog.csdn.net/puttytree/article/details/7825709 NumberUtil.h // // NumberUtil.h // MinaC ...
- Java 字节数组类型(byte[])与int类型互转
代码如下: public class CommonUtils { //高位在前,低位在后 public static byte[] int2bytes(int num){ byte[] result ...
- QT下int与QByteArray的转换
int转QByteArray QByteArray intToByte(int i) { QByteArray abyte0; abyte0.resize(4); abyte0[0] = (uchar ...
- Java中int类型和tyte[]之间转换及byte[]合并
JAVA基于位移的 int类型和tyte[]之间转换 [java] view plaincopy /** * 基于位移的int转化成byte[] * @param int number * @retu ...
随机推荐
- vs2015打开慢的解决方法
1.首先是这里,这里默认是用的软件加速,把"基于客户端性能自动调整视觉体验"去掉勾选.然后把下面的第一个选项去掉,第二选项勾选.我在想,它的"自动"基于 ...
- ④NuPlayer播放框架之Renderer源码分析
[时间:2016-11] [状态:Open] [关键词:android,nuplayer,开源播放器,播放框架,渲染器,render] 0 导读 之前我们分析了NuPlayer的实现代码,本文将重点聚 ...
- 100种不同图片切换效果插件pageSwitch
分享100种不同图片切换效果插件pageSwitch.这是一款适用于全屏切换场景,即一切一屏,并且实现了超过一百种切换效果,支持自定义切页动画.效果图如下: 在线预览 源码下载 实现的代码. ht ...
- Ramda函数式编程之PHP
0x00 何为函数式编程 网上已经有好多详细的接受了,我认为比较重要的有: 函数是"第一等公民",即函数和其它数据类型一样处于平等地位 使用"表达式"(指一个单 ...
- mysql+redis
微博的系统架构,想用mysql+redis配合使用,具体操作步骤: 写入数据到Redis,,然后在写个运行cron的脚本,美妙读内存,并写入数据库即可. 使用注意: 1.MySQL使用需要注意的地方: ...
- Linux权限详解 命令之 chmod:修改权限
权限简介 Linux系统上对文件的权限有着严格的控制,用于如果相对某个文件执行某种操作,必须具有对应的权限方可执行成功. Linux下文件的权限类型一般包括读,写,执行.对应字母为 r.w.x. Li ...
- 设计模式-行为型模式,python访问者模式
访问者模式 在访问者模式(Visitor Pattern)中,我们使用了一个访问者类,它改变了元素类的执行算法.通过这种方式,元素的执行算法可以随着访问者改变而改变.这种类型的设计模式属于行为型模式. ...
- 富可视M310刷机包 MIUIV5 红米开发版 闪光 美化 稳定
ROM介绍 MIUI 开发版 4.10.2 ·A2版为功能版(功能比較多.带相机切换和相机声音开关) ·更新最新图库 ·更新最新miui6的720P背板 ·更新miui6最新开机动画 [刷机提示]: ...
- 网络编程 -- RPC实现原理 -- NIO多线程 -- 迭代版本V1
网络编程 -- RPC实现原理 -- 目录 啦啦啦 V1——设置标识变量selectionKey.attach(true);只处理一次(会一直循环遍历selectionKeys,占用CPU资源). ( ...
- SpringBoot(十五)-- 修改SpringBoot默认的错误页面
将以下代码放置到 main方法中.然后在resources 中的static中新建404.html.405.html,这里可以自定义错误编码,不局限于这两个. @Bean public Embedde ...