[FAQ] ERROR 1264 (22003): Out of range value for column or constants overflows int

[问题澄清]

insert sql 遇到报错 ERROR 1264 (22003): Out of range value for column 或者 constants overflows int

[原因分析]

插入的值超过了 int 范围 , int 的取值 范围 为(-2147483648~2147483647),占用4个字节(-2的31次方到2的31次方-1)

[解决方案]

修改 int 为 bigint 类型,满足需要插入值的范围

举例:

MySQL [ryl]> insert into ryl values(2147483647);

Query OK, 1 row affected (0.02 sec)

MySQL [ryl]> insert into ryl values(2147483648);

ERROR 1264 (22003): Out of range value for column ‘a’ at row 1

MySQL [ryl]> alter table ryl modify a bigint;

Query OK, 0 rows affected (0.10 sec)

MySQL [ryl]> insert into ryl values(2147483648);

Query OK, 1 row affected (0.02 sec)

image

[参考案例]