int(11) vs. int(anything else)

前端 未结 7 1970
借酒劲吻你
借酒劲吻你 2020-11-27 15:19

I\'m new to web programming and doing different tutorials that I can find on the net.

I did my research and found out that in int(11), 11 is the maximum display widt

相关标签:
7条回答
  • 2020-11-27 16:03

    I agree that the MySQL manual is a little vague on the length/display width of integers. You might think that this limits the value you can store in the column to the number of digits but the valid range of the colomn doesnt change, wether you set it to 1 or 11.

    What it really does is determine the display width of the column's value. The only case this is usefull is if you use ZEROFILL to pad your values with zero's.

    So basically there is no real difference between INT(1) and INT(11) in terms of what you can store in the column, the only case when it becomes relevant is when you want to ZEROFILL your values.

    More info:
    http://alexander.kirk.at/2007/08/24/what-does-size-in-intsize-of-mysql-mean/
    http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html

    0 讨论(0)
提交回复
热议问题