Why can't I insert 10 digits when my column is INT(10)

后端 未结 6 1737
孤独总比滥情好
孤独总比滥情好 2021-01-17 05:24

I have this column that\'s INT(10) ZEROFILL NOT NULL DEFAULT \'0000000000\',

But when I insert something like 9100000010, I get 42949

6条回答
  •  滥情空心
    2021-01-17 06:15

    Largest value possible in INT field in MySQL is 2147483647, your value 9100000010 is greater than that. That is why it is overflowing to 4294967295 which is Max for Unsigned Integer.

    11.1.4.1. Integer Types (Exact Value)

    INT    4    -2147483648 2147483647
    

    Use BIGINT if you want to store larger number, which ranges from:

    BIGINT  8   -9223372036854775808    9223372036854775807
    

提交回复
热议问题