MySQL超出十进制列的范围值 [英] MySQL out of range value for decimal column

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

问题描述

搜索后,我发现许多人无法解决的问题是,他们不知道十进制(m,n)中的第一个数字m是数字的总数。但是,这不是我的问题。



对于所涉及的列,我有以下内容:

 字段|类型空|关键默认值|额外的
preco |十进制(50,2)无符号|否| | 0.00 |

设置小数(50,2)比我真正想要或需要的更多。我真的只想要10位数字。它的价格很高,所以任何超过1亿的价格可能都是荒谬的,因此,十进制(10,2)可能更合适。但是,MySQL不接受以下查询:

  INSERT INTO`produto`(`tipo_id`,`preco`,`qtd `,ʻopcao1`)值(110,'77888555.43','10','Azul')

我尝试通过CodeIgniter,phpMyAdmin以及直接在MySQL命令行客户端中进行查询。我也尝试了不带小数点的引号,但总是收到相同的错误:



第2行的'preco'列的值超出范围

解决方案

我已经尝试过 SQLyog ,它运行完美。我试图直接通过表数据选项卡并使用查询在 SQLy 中更改两种方式。它正在工作。似乎在十进制范围中没有问题,但问题出在其他地方。直接查看

直接通过表数据选项卡


通过插入查询


表结构


希望有帮助...


After searching, I found plenty of out of range problems with people not knowing that the first digit, m, in decimal(m,n) is the total amount of digits. However, that is not my problem.

For the column in question I have the following:

Field | Type                   | Null | Key | Default | Extra
preco | decimal(50,2) unsigned | NO   |     | 0.00    |

The setting decimal(50,2) is way more than I really want or need. I really only want 10 digits total. Its a price, so anything over 100 million is probably ridiculous, so decimal(10,2) would probably be more appropriate. However, MySQL Is not accepting the following query:

INSERT INTO `produto` (`tipo_id`, `preco`, `qtd`, `opcao1`) VALUES (110, '77888555.43', '10', 'Azul')

I tried the query through CodeIgniter, phpMyAdmin and directly in the MySQL command line client. I also tried it without the quotes on the decimal value but I always get the same error:

"Out of range value for column 'preco' at row 2"

解决方案

I have tried it with SQLyog, it is working perfect. I tried to change both ways in SQLyog directly through Table Data tab and using Query. It is just working. it seems there is no problem in Decimal Range, but problem is some where else. See the screenshots attached

Directly through Table Data Tab

Through insert query

Table Structure

Hope it help...

这篇关于MySQL超出十进制列的范围值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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