MySQL – Why is Default Width for Signed MEDIUMINT 9 Instead of 8?

MySQLmysql-5.5mysql-5.6

If I create a signed MEDIUMINT column without a width specifier, MySQL automatically adds a width of 9. However, the range of a signed MEDIUMINT is -8388608 to 8388607, which only needs 8 display characters max including the sign.

I tested all the other *INT types without a width and the default width MySQL assigned matched the worst case maximum number of characters needed to output the datatype. Why does a signed MEDIUMINT default to +1 character?

https://dev.mysql.com/doc/refman/5.7/en/integer-types.html

Best Answer

Hmmm... Sounds like a bug. But since that number is not used for anything (assuming you don't have ZEROFILL), then it is no big deal.

You could, if you like, file a bug report at bugs.mysql.com .