Mysql int(11) number out of range

后端 未结 3 1322
梦如初夏
梦如初夏 2020-12-03 06:59

I have a column which is set to int(20) when I try and insert a number like 622108120237, it says it\'s out of range. Why?

3条回答
  •  情话喂你
    2020-12-03 07:12

    See the MySQL Numeric Type Documentation. These things are well-documented.

    The range for a signed INT is [-2147483648, 2147483647].

    Note that in the case of INT(x), x is the "display width" and has nothing to do with the range or space requirements:

    MySQL supports an extension for optionally specifying the display width of integer data types in parentheses following the base keyword for the type. For example, INT(4) specifies an INT with a display width of four digits ... display width does not constrain [or expand] the range of values that can be stored in the column.

    Happy coding.

提交回复
热议问题