What does INT(5) in mysql mean?

前端 未结 7 415
孤独总比滥情好
孤独总比滥情好 2020-12-29 18:27

I always thought INT(5) means a number which has a max size of 5 digits. I tried entering a huge number inside it and it somehow got cut down to 2147483647

This obvi

7条回答
  •  一整个雨季
    2020-12-29 19:13

    A very common misconception about what int(N) means in MySQL is that the column can store maximum integer value with N digits in length. However, this is not true. int(N) does not determines the maximum value that the column can store in it. N is the display width of the integer column, unlike the characters columns where the number means number of character that can be stored.

    The number in the parenthesis does not determines the max and min values that can be stored in the integer field. The max and min values that can be stored are always fixed. The following table shows the required storage and range for each integer type.

提交回复
热议问题