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)?

2

2 Answers 2

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

1
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).

3
  • 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.
    – user330315
    Jun 25, 2013 at 19:26
  • This will help us bajb.net/2008/10/mysql-int1-or-int10
    – Pratik
    Jun 26, 2013 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. Jun 26, 2013 at 18:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.