When creating a table we normally make id field of integer type. But if I don't specify any value in length field how much length data will it store?
            Asked
            
        
        
            Active
            
        
            Viewed 2.1k times
        
    3
            
            
        - 
                    possible duplicate of [MySQL INT meaning](http://stackoverflow.com/questions/6817479/mysql-int-meaning) – JJJ Mar 15 '13 at 07:01
 - 
                    Length doesn't specify the size of the data it will store, but the size of the field used to display it. – JJJ Mar 15 '13 at 07:02
 
2 Answers
7
            
            
        I found an explanation elsewhere that says the value/length you specify when creating a numeric column only comes into play if you are using zerofill queries. Example here.
If you stored a value of 5
INT(4) would display 0005
INT(11) would display 00000000005
There's a note in mysql docs that tells of possible trouble when making it too small, so personally I just leave it blank when making a new numeric column.
0
            Juhana thanks for your link and answer. I got it. Length is for displaying how many characters will be shown and not how much data can be stored. So if I say integer type length is 3 then id will display upto 999 but will store values beyond that. I hope I got it right.
        Rolen Koh
        
- 719
 - 2
 - 11
 - 21
 
- 
                    2Well, not exactly. See the quote in the duplicate: *"The display width does not constrain the range of values that can be stored in the column. **Nor does it prevent values wider than the column display width from being displayed correctly.**"* If you have values >999 in a field with length 3, the values are shown correctly but the layout might break. It's basically just for making sure columns line up nicely when showing the table data. – JJJ Mar 15 '13 at 07:27