如何在MySQL中存储小数? [英] How to store decimal in MySQL?

查看:1052
本文介绍了如何在MySQL中存储小数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将DECIMAL与(2,2)一起使用,但不允许我使用它.

I've tried using DECIMAL with (2,2) but it won't let me use this.

我只想存储一个数字,例如7.50或10.50.我需要将两个数字都保留在小数点后,但是当我刷新数据库时,它将值重置为0.99.有什么建议吗?

I simply want to store a number, for example 7.50 or 10.50. I need to keep both numbers after the decimal though but when I refresh the database it resets the values to 0.99. Any suggestions?

推荐答案

DECIMAL声明的第一位数字是总数位数字.您可能要使用DECIMAL (4, 2).这样最多可以在小数点前两位和后两位.

The first digit of the DECIMAL declaration is the total digits. You probably want to use DECIMAL (4, 2). This allows for up to two digits before the decimal and two after.

文档: https://dev. mysql.com/doc/refman/5.7/en/precision-math-decimal-characteristics.html

这篇关于如何在MySQL中存储小数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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