In short, it really doesn’t matter. After watching a MySQL web conference by Jay Pipes, I was gutted when I found out that they are actually exactly the same. I know im not alone in thinking that it affected the size of the data field. An unsigned int has the max value of 4294967295 no matter if its INT(1) or int(10) and will use 4 bytes of data.
So, what does the number in the brackets mean? It pretty much comes down to display, its called the display-width. The display width is a number from 1 to 255. You can set the display width if you want all of your integer values to “appear”. If you enable zerofill on the row, the field will have a default value of 0 for int(1) and 0000000000 for int(10).
There are 5 main numeric data types, and you should choose each one on its own merits. Based on the data you expect (or in some cases hope) to hold, you should use the correct data type. If you dont ever expect to use a value of above 127 and below -128, you should use a tinyint. This will only use 1 byte of data, which may not seem like much of a difference between the 4 used by an int, but as soon as you start to store more and more data, the effect on speed and space will be noticable.
Anyway, I thought I should share my new found knowledge of the display width with everyone, because it will save me thinking its optimising stuff changing from 10 to 5, haha.
Just what I was looking for. Thanks for the clear explanation!
I never knew that! Every day’s a school day!
brilliant!
i was always under the assumption that this affected the data inside the column in some way!
thank you kindly for the clear and precise description!
thanks for the information!
haven’t knew it yet, but is pretty nice to know
thanks for the explanation!
Cool post. Google’d what int(10) meant and found your post right away. Thanks for ur knowledge
I suspected as such, thanks for clearly defining it for me.
Thanks, new thing for me as i was in wrong assumption about INT(4) and INT(10)
Thanks buddy…!!
thanks for the display width info..
Many thanks for your clear explanation..
Wow. I had no idea. I’ve been wasting my time doing that!!!! Thanks for the info. I’m thinking back now to all the time I wasted thinking about whether to make a field int(5) or int(6) etc. Now I know : – ).
I’ve spent literally HOURS searching the web for an explanation!!!
Very nice and simple explanation. Many thanks for that!
)
This is really a useful information . Thanks lot dude
Hey! Very thanks! This is the answer that i have search.
Great info. As some of them said – Clear, precise explanation. Found as the first result on Google when searched for ‘mysql int(1)’ .
Thanks for good explanation and information sharing
I like great and simply explanation.Thanks for interesting post!
thx. this helped too. fortunately did not burn hours on it.
http://matthom.com/archive/2006/11/28/mysql-integer-columns-and-display-width
Really helps a lot …….. Thank you
Thx!
Thanks for the post, helped clear things up for me
thank for your sharing, now I get that
Thanks for the info, one of the very basic things but didn’t knew till now.. thank you
Thank you for a good explanation. For a long time I thought I was beening clever using smaller indices, but now I know
I had a alittle idea that it doesn’t make that much of a difference but was looking for a precise answer and your post did just that. Thank you
thanks for the explanation!
Thanks..this is what i wanted to know..