What is the impact of declaring a field as INT(x)
versus INT(x+1)
in MySQL? What happens if I try to enter 12345
into an INT(4)
field? What happens when I query it?
Asked
Active
Viewed 114 times
-1
-
I have read the MySQL docs, I still don't understand what it means. – JDelage Oct 13 '12 at 23:36
1 Answers
2
It's about the display width. You only see it when you use ZEROFILL.
As copied from MySQL docs:
M
indicates the maximum display width for integer types. The maximum legal display width is 255. Display width is unrelated to the range of values a type can contain, as described in Section 11.1.4, “Numeric Types”. For floating-point and fixed-point types, M
is the total number of digits that can be stored.
If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED
attribute to the column.
Numeric data types that permit the UNSIGNED
attribute also permit SIGNED
. However, these data types are signed by default, so the SIGNED
attribute has no effect.

hjpotter92
- 78,589
- 36
- 144
- 183
-
Yes, I have read the doc. I don't understand it, this is why I'm posting here. – JDelage Oct 13 '12 at 23:36
-
1@JDelage Read [this](http://alexander.kirk.at/2007/08/24/what-does-size-in-intsize-of-mysql-mean/) page then. This has been written from a newbie's POV. – hjpotter92 Oct 13 '12 at 23:56
-
Thanks. So it's just used for ZEROFILL? If I don't use ZEROFILL, I should just leave it blank? – JDelage Oct 14 '12 at 00:02
-
@JDelage Yep! You can always leave it to blank except its not advised for other data-types. – hjpotter92 Oct 14 '12 at 00:05