问题描述
我知道 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) - 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)