mysql tinyint(1) vs tinyint(2) vs tinyint(3) vs tinyint(4)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13120904/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mysql tinyint(1) vs tinyint(2) vs tinyint(3) vs tinyint(4)
提问by Tarun Gupta
Possible Duplicate:
MySql: Tinyint (2) vs tinyint(1) - Which difference?
What is the difference between:
有什么区别:
TinyINT(1)
TinyINT(2)
TinyINT(3)
TinyINT(4)
TinyINT(1)
TinyINT(2)
TinyINT(3)
TinyINT(4)
回答by muehlbau
TinyINT(M) always has a range from -128..+127 signed or 0..255 unsigned. M is the display width.
TinyINT(M) 的范围始终为 -128..+127 有符号或 0..255 无符号。M 是显示宽度。
M indicates the maximum display width for integer types. The maximum display width is 255. Display width is unrelated to the range of values a type can contain, as described in Section 11.2, “Numeric Types”. For floating-point and fixed-point types, M is the total number of digits that can be stored.
M 表示整数类型的最大显示宽度。最大显示宽度为 255。显示宽度与类型可以包含的值范围无关,如第 11.2 节“数字类型”中所述。对于浮点和定点类型,M 是可以存储的总位数。
from http://dev.mysql.com/doc/refman/5.5/en/numeric-type-overview.html
来自http://dev.mysql.com/doc/refman/5.5/en/numeric-type-overview.html
回答by Vyktor
According to Mysql manualall decimal numeric types supports syntax:
根据Mysql 手册,所有十进制数字类型都支持语法:
Integer Types (Exact Value)
When using DECIMAL
it allows you to specify precision.
使用DECIMAL
它时,您可以指定 precision。
With *INT
types it's has mainly display functionwhich also specifies how many places should be added when using ZEROFILL
.
对于*INT
类型,它主要具有显示功能,该功能还指定使用ZEROFILL
.
The byte size remains unaffected (1B
for TINYINT
).
字节大小不受影响(1B
forTINYINT
)。
回答by Francois
TinyINT = -128...+127
TinyINT = -128...+127
(n) is for display purposes.
(n) 用于显示目的。