MySql: Tinyint (2) vs tinyint(1) - what is the difference?(MySql: Tinyint (2) vs tinyint(1) - 有什么区别?)
问题描述
我知道 mysql 中的布尔值是 tinyint (1).
I knew boolean in mysql as tinyint (1).
今天我看到一个表定义了一个整数,比如 tinyint(2),还有其他的比如 int(4), int(6)代码> ...
Today I see a table with defined an integer like tinyint(2), and also others like int(4), int(6) ...
integer 和 tinyint 类型的字段中的大小是什么意思?
What does the size means in field of type integer and tinyint ?
推荐答案
表示显示宽度
无论您使用 tinyint(1) 还是 tinyint(2),都没有任何区别.
Whether you use tinyint(1) or tinyint(2), it does not make any difference.
我总是使用 tinyint(1) 和 int(11),我使用了几个 mysql 客户端(navicat、sequel pro).
I always use tinyint(1) and int(11), I used several mysql clients (navicat, sequel pro).
它根本没有任何意义!我跑了一个测试,上面的客户端甚至命令行客户端似乎都忽略了这一点.
It does not mean anything AT ALL! I ran a test, all above clients or even the command-line client seems to ignore this.
但是,如果您使用 ZEROFILL 选项,显示宽度 是最重要的,例如您的表格有以下 2 列:
But, display width is most important if you are using ZEROFILL option, for example your table has following 2 columns:
A tinyint(2) zerofill
A tinyint(2) zerofill
B tinyint(4) zerofill
B tinyint(4) zerofill
两列的值都是 1,A 列的输出将是 01 和 0001 对于 B,如下面的截图所示:)
both columns has the value of 1, output for column A would be 01 and 0001 for B, as seen in screenshot below :)
这篇关于MySql: Tinyint (2) vs tinyint(1) - 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MySql: Tinyint (2) vs tinyint(1) - 有什么区别?
基础教程推荐
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 无法解决整理冲突 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
