2

I am too much confused in Length/Values column in phpmyadmin.

enter image description here

Can any one explain me, What is the difference between int(1) and int(2)?

Pratik
  • 810
  • 6
  • 26
  • Check out the manual: http://dev.mysql.com/doc/refman/5.5/en/numeric-type-attributes.html –  Jun 25 '13 at 19:27
  • 1
    possible duplicate of [MySQL INT meaning](http://stackoverflow.com/questions/6817479/mysql-int-meaning) or [int(11) vs. int(anything else)](http://stackoverflow.com/questions/7552223/int11-vs-intanything-else) –  Jun 25 '13 at 19:29

2 Answers2

2

Its called display width, It will take a whole int, but only will display the first x numbers (so 1 will display 1 number, 2 will display 2)

The whole int is stored so its not like varchar, IF you want less storage use a smaller type (tinyint would suffice for both 1 and 2)

The types and how much they can store are here

http://dev.mysql.com/doc/refman/5.0/en/integer-types.html

exussum
  • 18,275
  • 8
  • 32
  • 65
1

I believe that is the "width" or size of your number. int(2) means that it can be two digits, and int(3) means three digits, so on and so forth. I could be wrong, but let me know if this answers your question!

I know it works this way for varchar(n), so I'm thinking it's the same for int(n).

Ricky Mutschlechner
  • 4,291
  • 2
  • 31
  • 36
  • That's wrong. It simply is a hint for the application (client) on how wide the number should be displayed. It does not influence the values that can be stored in the value in any way. –  Jun 25 '13 at 19:26
  • This will help us http://www.bajb.net/2008/10/mysql-int1-or-int10/ – Pratik Jun 26 '13 at 17:36
  • Okay, TECHNICALLY it doesn't control the size in terms of digits, but it controls how many are displayed. Isn't "displaying" 1 digit out of however many the same exact thing as only having a 1 digit number? It isn't exactly the same - but what I'm saying is that in terms of actually displaying the field, it is the same. I did say the "width" of the number in my original answer - I gave the example that int(2) means two digits, int(3) is three digits, etc. My answer isn't incorrect, at all, from what I know. Please correct me if I'm wrong - I'd appreciate knowing. – Ricky Mutschlechner Jun 26 '13 at 18:49