Mysql 错误1264(22003):第1行“金额”列的值超出范围

Mysql 错误1264(22003):第1行“金额”列的值超出范围,mysql,Mysql,使用此命令: mysql> insert into irctc_cap ( lid,amount,type) VALUES (296,-1000,128); ERROR 1264 (22003): Out of range value for column 'amount' at row 1 Mysql版本:14.14版发行版5.7.19 据我所知,这个问题不应该出现,因为金额的长度为12,4 如果数据类型为DECIMAL5,2,则表示总共五位数字,其中两位位于小数点右侧。因此,可以

使用此命令:

mysql>  insert into irctc_cap ( lid,amount,type) VALUES (296,-1000,128);

ERROR 1264 (22003): Out of range value for column 'amount' at row 1
Mysql版本:14.14版发行版5.7.19

据我所知,这个问题不应该出现,因为金额的长度为12,4

如果数据类型为DECIMAL5,2,则表示总共五位数字,其中两位位于小数点右侧。因此,可以使用的最大值是999.99,最小值是-999.99。这是五位数中最多的数字

如果不使用严格模式,将生成警告并将尝试使用的值截断为五位数:

mysql> insert into irctc_cap values (296,-1000,128);
Query OK, 1 row affected, 1 warning (0.02 sec)

mysql> show warnings;
+---------+------+-------------------------------------------------+
| Level   | Code | Message                                         |
+---------+------+-------------------------------------------------+
| Warning | 1264 | Out of range value for column 'amount' at row 1 |
+---------+------+-------------------------------------------------+
1 row in set (0.00 sec)

mysql> select * from irctc_cap;
+------+---------+------+
| lid  | amount  | type |
+------+---------+------+
|  296 | -999.99 |  128 |
+------+---------+------+
如果使用严格模式,警告将变为错误:

mysql> set sql_mode=strict_all_tables;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into irctc_cap values (296,-1000,128);
ERROR 1264 (22003): Out of range value for column 'amount' at row 1
我不知道为什么phpMyAdmin显示了错误的数据类型


使用“描述”或“显示创建表”或“从信息模式中选择列类型”。表中的列“irctc\u cap”和列“NAME='amount”可获得列的准确定义。

如果金额定义为无符号,则会出现此错误。图像来自哪个ide?@P.Salmon我没有在该字段的任何位置使用unsigned,您似乎正在使用PhpMyAdmin。向右滚动并查看属性。抱歉,使用desc它显示为'decimal5,2'。我要加大尺寸。Phpmyadmin显示为12,4