MySQL 错误:列 'amount' 的值超出范围在第 1 行 [英] MySQL Error: Out of range value for column 'amount' at row 1

查看:77
本文介绍了MySQL 错误:列 'amount' 的值超出范围在第 1 行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MySQL

create table tran (
id int,
amount float(9,3)
);

insert into tran (id, amount) values (1, -1000000)
;

错误:第 1 行金额"列的值超出范围

Error: Out of range value for column 'amount' at row 1

-1000000 的数量是 7 位,那么浮点数中的 9 会不会绰绰有余?

The amount of -1000000 is 7 digits, so wouldnt the 9 in the float be more than enough?

手册上说(M,D) 表示可以存储最多 M 位数字的值"

The manual says "(M,D) means than values can be stored with up to M digits in total"

http://dev.mysql.com/doc/refman/5.7/en/floating-point-types.html

http://sqlfiddle.com/#!9/aa6cc

推荐答案

FLOAT(9,3) 意思是:

  • 9 总共 个精度单位
  • 小数点后 3 个单位,因此
  • 只有 6 个单位小数点
  • 9 total units of precision
  • with 3 units past the decimal place, hence
  • only 6 units before the decimal place


如果您想要 9 位非十进制精度,请使用 FLOAT(12, 3).

If you want 9 digits of non-decimal precision then use FLOAT(12, 3).

看看 MySQL 文档.

Have a look at the MySQL documentation.

这篇关于MySQL 错误:列 'amount' 的值超出范围在第 1 行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆