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

查看:334
本文介绍了MySQL错误:第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错误:第1行的列“金额"超出范围的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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