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

后端 未结 6 1786
孤独总比滥情好
孤独总比滥情好 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:08

    Int has maximum value range :

    INT 4   -2147483648 2147483647
            0   4294967295 (unsigned )
    

    hence, you are getting the maximum value due to the overflow. use bigint instead, which has 8 bytes and you shall be fine.

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

    BIGINT  8   -9223372036854775808    9223372036854775807
              0                 18446744073709551615
    

提交回复
热议问题