MySQL datatype INT(11) whereas UNSIGNED INT(10)?

后端 未结 3 1816
傲寒
傲寒 2021-02-02 05:45

in MySQL if we create a field dataType of INT and does not specify any length/values then it automatically became int(11) and if we set the attribute

3条回答
  •  有刺的猬
    2021-02-02 06:16

    According to the documentation, this number is merely the display width.

    For example, INT(4) specifies an INT with a display width of four digits.

    The display width does not constrain the range of values that can be stored in the column. Nor does it prevent values wider than the column display width from being displayed correctly. For example, a column specified as SMALLINT(3) has the usual SMALLINT range of -32768 to 32767, and values outside the range permitted by three digits are displayed in full using more than three digits.

    The default display width for an UNSIGNED INT is one fewer than that for a non-UNSIGNED INT simply because you will never be displaying a - character.

    Note that you can still specify whatever display width you like. This is just the default.

    The use of the term "digits" in the documentation is slightly misleading here.

提交回复
热议问题