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 ...
随机推荐
- KMP算法——从入门到懵逼到了解
本博文參考http://blog.csdn.net/v_july_v/article/details/7041827 关于其它字符串匹配算法见http://blog.csdn.net/WINCOL/a ...
- Socket网络编程--网络爬虫(1)
我们这个系列准备讲一下--网络爬虫.网络爬虫是搜索引擎系统中十分重要的组成部分,它负责从互联网中搜集网页,采集信息,这些网页信息用于建立索引从而为搜索引擎提供支持,它决定着整个引擎系统的内容是否丰富, ...
- 申请IPV6地址配置IPV6域名
0. 前言 最近弄了一下IPV6,虽然不知道什么时候会用到,但是服务器支持IPV6,还是有必要的. 1. 申请IPV6地址 https://tunnelbroker.net/ 到这个网址去注册一个帐号 ...
- 20款最好的jQuery文件上传插件
当它是关于开发网络应用程序和网页的时候,文件上传功能的重要性是不容忽视的.一个文件上传功能可以让你上传所有类型的文件在网站上,包括视频,图像,文件和更多.创建一个文件上传功能,对你的网站是不是很难,有 ...
- 2. Attention Is All You Need(Transformer)算法原理解析
1. 语言模型 2. Attention Is All You Need(Transformer)算法原理解析 3. ELMo算法原理解析 4. OpenAI GPT算法原理解析 5. BERT算法原 ...
- Android ShareUserId 使用总结
今天讲一下Android里面经常看到却不太留意的知识点——ShareUserId,在Android里面每个app都有一个唯一的linux user ID,则这样权限就被设置成该应用程序的文件只对该用户 ...
- MyBatis XML转义字符
当我们需要通过xml格式处理sql语句时,经常会用到< ,<=,>,>=等符号,但是很容易引起xml格式的错误,这样会导致后台将xml字符串转换为xml文档时报错,从而导致程序 ...
- 网络协议TCP/IP、IPX/SPX、NETBEUI简介
网络中不同的工作站,服务器之间能传输数据,源于协议的存在.随着网络的发展,不同的开发商开发了不同的通信方式.为了使通信成功可靠,网络中的所有主机都必须使用同一语言,不能带有方言.因而必须开发严格的标准 ...
- Apache重写规则由浅入深剖析.htaccess
1..htaccess文件使用前提 .htaccess的主要作用就是实现url改写,也就是当浏览器通过url访问到服务器某个文件夹时,作为主人,我们可以来接待这个url,具体 地怎样接待它,就是此文件 ...
- Git 删除提交记录
.Checkout git checkout --orphan latest_branch 2. Add all the files git add -A 3. Commit the changes ...