myql中的decimal
来源:互联网 发布:rs422 转网络 编辑:程序博客网 时间:2024/06/05 18:37
原文:http://dev.mysql.com/doc/refman/5.6/en/precision-math-decimal-characteristics.html
myql中的decimal
mysql 的每个字段类型之间的差别虽小,但是在海量数据当中还是能提现出来的。
列的声明语法是DECIMAL(M,D)。在MySQL 5.1中,参量的取值范围如下:
·M是数字的最大数(精度)。其范围为1~65(在较旧的MySQL版本中,允许的范围是1~254),M的默认值是10。
·D是小数点右侧数字的数目(标度)。其范围是0~30,但不得超过M。
说明:float占4个字节,double占8个字节,decimail(M,D)占M+2个字节。
如DECIMAL(5,2) 的最大值为9 9 9 9 . 9 9,因为有7 个字节可用。
This section discusses the characteristics of the DECIMAL
data type (and its synonyms) in MySQL 5.6, with particular regard to the following topics:
Maximum number of digits
Storage format
Storage requirements
The nonstandard MySQL extension to the upper range of
DECIMAL
columns
Possible incompatibilities with applications that are written for older versions of MySQL (prior to 5.0.3) are noted throughout this section.
The declaration syntax for a DECIMAL
column is DECIMAL(
. The ranges of values for the arguments in MySQL 5.6 are as follows:M
,D
)
M
is the maximum number of digits (the precision). It has a range of 1 to 65. (Older versions of MySQL permitted a range of 1 to 254.)D
is the number of digits to the right of the decimal point (the scale). It has a range of 0 to 30 and must be no larger thanM
.
The maximum value of 65 for M
means that calculations on DECIMAL
values are accurate up to 65 digits. This limit of 65 digits of precision also applies to exact-value numeric literals, so the maximum range of such literals differs from before. (In older versions of MySQL, decimal values could have up to 254 digits. However, calculations were done using floating-point and thus were approximate, not exact.)
Values for DECIMAL
columns in MySQL 5.6 are stored using a binary format that packs nine decimal digits into 4 bytes. The storage requirements for the integer and fractional parts of each value are determined separately. Each multiple of nine digits requires 4 bytes, and any remaining digits left over require some fraction of 4 bytes. The storage required for remaining digits is given by the following table.
For example, a DECIMAL(18,9)
column has nine digits on either side of the decimal point, so the integer part and the fractional part each require 4 bytes. ADECIMAL(20,6)
column has fourteen integer digits and six fractional digits. The integer digits require four bytes for nine of the digits and 3 bytes for the remaining five digits. The six fractional digits require 3 bytes.
Unlike some older versions of MySQL, DECIMAL
columns in MySQL 5.6 do not store a leading +
character or -
character or leading 0
digits. If you insert +0003.1
into aDECIMAL(5,1)
column, it is stored as 3.1
. For negative numbers, a literal -
character is not stored. Applications that rely on the older behavior must be modified to account for this change.
DECIMAL
columns in MySQL 5.6 do not permit values larger than the range implied by the column definition. For example, a DECIMAL(3,0)
column supports a range of-999
to 999
. A DECIMAL(
column permits at most M
,D
)M
- D
digits to the left of the decimal point. This is not compatible with applications relying on older versions of MySQL that permitted storing an extra digit in lieu of a +
sign.
The SQL standard requires that the precision of NUMERIC(
be exactly M
,D
)M
digits. For DECIMAL(
, the standard requires a precision of at least M
,D
)M
digits but permits more. In MySQL, DECIMAL(
and M
,D
)NUMERIC(
are the same, and both have a precision of exactly M
,D
)M
digits.
For a full explanation of the internal format of DECIMAL
values, see the file strings/decimal.c
in a MySQL source distribution. The format is explained (with an example) in the decimal2bin()
function.
For more detailed information about porting applications that rely on the old treatment of the DECIMAL
data type, see the MySQL 5.0 Reference Manual.
- myql中的decimal
- mysql中的decimal类型
- C#中的decimal类型
- mysql 中的decimal
- 数据库中的decimal、enum字段
- db2 中的DECIMAL 数字数据类型
- Mysql中的decimal是什么类型
- C#中的Decimal的四舍五入
- Decimal
- Decimal
- Decimal
- Decimal
- decimal
- Decimal类型在地图坐标中的运用
- Oracle中的decimal与Number区别
- MYSQL中的FLOAT、DOUBLE和DECIMAL类型
- [Oracle]Oracle中的decimal与Number区别
- 得到AppSettings中的配置Decimal信息
- 第九周 项目2-2 压缩存储的对称矩阵的运算
- PopupWindow如何右对齐
- 简易聊天室
- 进程状态变换模拟
- HDOJ 1870 愚人节的礼物 (stack)
- myql中的decimal
- angularjs 学习笔记
- 短信接口源码(实现按钮倒计时的功能)
- Android ScrollView+ViewPager+ListView一起使用
- 需求分析的目标
- 第七周:顺序环形队列
- 深入理解先进的自动布局工具箱
- bit是什么,和字节byte什么关系(2015年10月22日)
- Virtualbox WDDM之DxgkDdiIsSupportedVidPn