MySql:Tinyint(2)vs tinyint(1)-有什么区别? [英] MySql: Tinyint (2) vs tinyint(1) - what is the difference?

查看:861
本文介绍了MySql:Tinyint(2)vs tinyint(1)-有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道mysql中的布尔值为tinyint (1).

今天,我看到一个表,该表定义了一个整数,例如tinyint(2),还定义了其他整数,例如int(4)int(6) ...

大小在integer和tinyint类型的字段中意味着什么?

解决方案

这表示显示宽度

无论您使用tinyint(1)还是tinyint(2),它都没有任何区别.

我总是使用tinyint(1)和int(11),我使用了几个mysql客户端(navicat,sequel pro).

这根本没有任何意义!我进行了测试,所有上述客户端甚至命令行客户端似乎都忽略了这一点.

但是,如果您使用的是ZEROFILL选项,则显示宽度最重要,例如您的表格有以下两列:

A tinyint(2)零填充

B tinyint(4)零填充

两列的值为1,列 A 的输出将为01 B 的输出为0001,如下面的屏幕截图所示:)

I knew boolean in mysql as tinyint (1).

Today I see a table with defined an integer like tinyint(2), and also others like int(4), int(6) ...

What does the size means in field of type integer and tinyint ?

解决方案

It means display width

Whether you use tinyint(1) or tinyint(2), it does not make any difference.

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.

But, display width is most important if you are using ZEROFILL option, for example your table has following 2 columns:

A tinyint(2) zerofill

B tinyint(4) zerofill

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆