What size INT should I use for my autoincrement ids MySQL?

The value within the brackets is the display width It may be used by applications to display integer values having a width less than the width specified for the column by left-padding them with spaces. (That is, this width is present in the metadata returned with result sets. Whether it is used or not is up to the application.) The display width does not constrain the range of values that can be stored in the column, nor the number of digits that are displayed for values having a width exceeding that specified for the column.

For example, a column specified as INT(3) has the usual INT range of -2147483648 to 2147483647, and values outside the range permitted by three characters are displayed using more than three characters Conclusion INT(10) or INT(21) doesn't impact the values that can be stored. If you really have a concern, the data type can easily be changed to be BIGINT with no reprocusions that I'm aware of. I'd look at how many new records are being created in a given period (IE a month) & see how long it'll take to max out the INT value based on that history.

The value within the brackets is the display width. It may be used by applications to display integer values having a width less than the width specified for the column by left-padding them with spaces. (That is, this width is present in the metadata returned with result sets.

Whether it is used or not is up to the application. ) The display width does not constrain the range of values that can be stored in the column, nor the number of digits that are displayed for values having a width exceeding that specified for the column. For example, a column specified as INT(3) has the usual INT range of -2147483648 to 2147483647, and values outside the range permitted by three characters are displayed using more than three characters.

Conclusion INT(10) or INT(21), doesn't impact the values that can be stored. If you really have a concern, the data type can easily be changed to be BIGINT with no reprocusions that I'm aware of. I'd look at how many new records are being created in a given period (IE a month) & see how long it'll take to max out the INT value based on that history.

Thank you for your detailed answer and the link. My ignorance, in this case, has been eradicated. – Michael Robinson Aug 25 '10 at 4:06 just a note, last month a co-worker noticed that the int number changes to a weird number when try to enter an 11 digits number, of course the column was set to int(10), I was told that the number will never exceed 10 digits but then it happens, increase from 10 to 11 and generate an duplicated number, thank G was not the id column but my question is, what would've happen if the id is set to int(11) and is exceeded?

An example of the weird number is from 12345678901 the numbered returned was 234567891 or something like that. – raphie Nov 20 at 19:01.

See here for the limit of each int type: dev.mysql.com/doc/refman/5.0/en/numeric-... Note that INT(21) == INT(100000). The number in brackets is just how many zeros are padded to it if you specify the field should be zero-padded. An unsigned int field can hold up to 4294967295 records (see link above).

Don't worry about taking too much space, space is cheap. Choose a column type that you know you won't exceed. You'll kick yourself when you choose smallint to save space and run into issues when your database won't hold anymore data.

If our database runs out of space, we'll have 4294967295 members. Then I'll be kicking myself alright, kicking myself all the way to the bank :) – Michael Robinson Aug 26 '10 at 8:51.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions