Home > Database > Mysql Tutorial > MySQL数据类型-decimal详解

MySQL数据类型-decimal详解

WBOY
Release: 2016-06-07 17:30:51
Original
2502 people have browsed it

对于精度比较高的东西,比如money,我会用decimal类型,不会考虑float,double,因为他们容易产生误差,numeric和decimal同义,num

1.首先,对于精度比较高的东西,,比如money,我会用decimal类型,不会考虑float,double,因为他们容易产生误差,numericdecimal同义,numeric将自动转成decimal

DECIMALMySQL 5.1中,参量的取值范围如下:

1

030,但不得超过M

DECIMAL(5,2) 的最大值为9 9 9 9 . 9 9,因为有7 个字节可用。

M D DECIMAL(M, D) 取值范围的影响

MySQL >= 3.23

DECIMAL(5,1) -99.9 999.9 -9999.9 99999.9

DECIMAL(6,1) -999.9 9999.9 -99999.9 999999.9

DECIMAL(6,2) -99.99 999.99 -9999.99 99999.99

DECIMAL(6,3) -9.999 99.999 -999.999 9999.999

#

结论:

当数值在其取值范围之内,小数位多了,则直接截断小数位。

若数值在其取值范围之外,则用最大()值对其填充。

推荐阅读:

MySQL备份和恢复具体实施

MySQL备份与恢复的三种方法总结

MySQL备份还原(视图、存储过程)  

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template