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

后端 未结 3 1860
傲寒
傲寒 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:17

    int value can be -2147483648 these are 11 digits so the default display size is 11

    unsigned int does not allow negative numbers so by default it need only display size 10

    As the documentation below shows, the number of bits required to store SIGNED INT and UNSIGNED INT is the same, the range of storable numbers is merely shifted:

    Unsigned type can be used to permit only nonnegative numbers in a column or when you need a larger upper numeric range for the column. For example, if an INT column is UNSIGNED, the size of the column's range is the same but its endpoints shift from -2147483648 and 2147483647 up to 0 and 4294967295.

    http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html

提交回复
热议问题