Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

This question already has an answer here:

I found out, that if you have a field defined as INT(8) without ZEROFILL it will behave exactly as INT(5)

in both cases the maximum value is

−2,147,483,648 to 2,147,483,647, from −(2^31) to 2^31 − 1

or do i miss something?

I found this Question: http://dba.stackexchange.com/a/370/12923

The (5) represents the display width of the field. From the manual, it states:

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. For example, a column specified as SMALLINT(3) has the usual SMALLINT range of -32768 to 32767, and values outside the range permitted by three digits are displayed in full using more than three digits.

The display width, from what I can tell, can be used to left-pad numbers that are less than the defined width. So 00322, instead of 322. TBH, I've never used it.

But it doesn't affect the storage size of the column. An int will take up more space than a smallint.

so there seems to be no difference then.

share|improve this question
1  
so I assume, I am right here: there is no difference. Only if I would use ZEROFILL, there would show a different behaviour in smaller numbers –  rubo77 Feb 9 '13 at 11:58
add comment

marked as duplicate by Paul White, RolandoMySQLDBA, Mark Storey-Smith, Max Vernon, Kin Feb 6 at 20:18

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

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

Essentially what you listed is the max value for INT and not BIGINT

INT(8) is the equivelent of typing INT with a display widdth of 8 digits, INT(4) is the equivelent of typing just INT with 4 display lengths.

The max value for BIGINT is -9223372036854775808 to 9223372036854775807 or 0 to 18446744073709551615.

share|improve this answer
    
i think that is not correct –  rubo77 Nov 29 '12 at 21:54
    
You're right, the 2nd sentence was incorrect. Updated it to include the right values! Upvoting question, good research. –  Ali Razeghi Nov 29 '12 at 22:01
    
thanks, but i think you are still wrong. int is always smaller than bigint. no matter which number you put behind –  rubo77 Nov 29 '12 at 22:03
5  
int(4) will store exactly the same values as int(8). As the manuals says: the number does not limit the value range. It's merely a hint to applications. –  a_horse_with_no_name Nov 29 '12 at 22:03
    
it is also a value used by the zerofill parameter –  rubo77 Nov 29 '12 at 22:04
show 3 more comments

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