[转帖]12.24.2 DECIMAL Data Type Characteristics
https://dev.mysql.com/doc/refman/8.0/en/fixed-point-types.html
This section discusses the characteristics of the DECIMAL data type (and its synonyms), with particular regard to the following topics:
Maximum number of digits
Storage format
Storage requirements
The nonstandard MySQL extension to the upper range of
DECIMALcolumns
The declaration syntax for a DECIMAL column is DECIMAL(. The ranges of values for the arguments are as follows:M,D)
Mis the maximum number of digits (the precision). It has a range of 1 to 65.Dis 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.
If D is omitted, the default is 0. If M is omitted, the default is 10.
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. (There is also a limit on how long the text of DECIMAL literals can be; see Section 12.24.3, “Expression Handling”.)
Values for DECIMAL columns 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.
| Leftover Digits | Number of Bytes |
|---|---|
| 0 | 0 |
| 1–2 | 1 |
| 3–4 | 2 |
| 5–6 | 3 |
| 7–9 | 4 |
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. A DECIMAL(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.
DECIMAL columns do not store a leading + character or - character or leading 0 digits. If you insert +0003.1 into a DECIMAL(5,1) column, it is stored as 3.1. For negative numbers, a literal - character is not stored.
DECIMAL columns 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 up to M,D)M - D digits to the left of the decimal point.
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.
[转帖]12.24.2 DECIMAL Data Type Characteristics的更多相关文章
- DECIMAL Data Type
In MySQL, DECIMAL(M,D) and NUMERIC(M,D) are the same, and both have a precision of exactly M digits. ...
- mysql data type <----> java data type (数值)
https://dev.mysql.com/doc/refman/5.7/en/storage-requirements.html +----------------------------+---- ...
- MySql and Oracle Data Type Mappings
the default settings used by SQL Developer to convert data types from MySQL to Oracle. SQL Developer ...
- 【转载】salesforce 零基础开发入门学习(四)多表关联下的SOQL以及表字段Data type详解
salesforce 零基础开发入门学习(四)多表关联下的SOQL以及表字段Data type详解 建立好的数据表在数据库中查看有很多方式,本人目前采用以下两种方式查看数据表. 1.采用schem ...
- salesforce 零基础开发入门学习(四)多表关联下的SOQL以及表字段Data type详解
建立好的数据表在数据库中查看有很多方式,本人目前采用以下两种方式查看数据表. 1.采用schema Builder查看表结构以及多表之间的关联关系,可以登录后点击setup在左侧搜索框输入schema ...
- The conversion of a varchar data type to a datetime data type resulted in an out-of-range value
刚刚有在程序中,传递一个空值至MS SQL Server数据库,这个值的数据类型为DATETIME执行时,它却发生了如标题提示的异常:The conversion of a varchar data ...
- Extended Data Type Properties [AX 2012]
Extended Data Type Properties [AX 2012] This topic has not yet been rated - Rate this topic Updated: ...
- 1月21日 Reference Data Type 数据类型,算法基础说明,二分搜索算法。(课程内容)
Reference Datat Types 引用参考数据类型 -> 组合数据类型 Array, Hash和程序员自定义的复合资料类型 组合数据的修改: 组合数据类型的变量,不是直接存值,而是存一 ...
- C++数据类型(data type)介绍
在编写程序时,数据类型(data type)定义了使用存储空间的(内存)的方式. 程序员通过定义数据类型(data type),告诉特定存储空间这里要存储的数据类型是什么,以及你即将操作他的方式.(注 ...
- How to check sqlsever table data type identity status ?
Unlike in Oracle, sqlserver has an special data type in order by make identity growth. But what abou ...
随机推荐
- vue 遍历的汉字显示不同的颜色
<template> <div> <div class="stars"> <span v-for="(star, index) ...
- 神经网络基础篇:史上最详细_详解计算图(Computation Graph)
计算图 可以说,一个神经网络的计算,都是按照前向或反向传播过程组织的.首先计算出一个新的网络的输出(前向过程),紧接着进行一个反向传输操作.后者用来计算出对应的梯度或导数.计算图解释了为什么用这种方式 ...
- 如何利用动态配置中心在JavaAgent中实现微服务的多样化治理
本文分享自华为云社区<如何利用动态配置中心在JavaAgent中实现微服务的多样化治理>,作者:华为云开源 . 一.前言 随着JavaAgent在微服务治理方面的广泛应用和发展,我们可以在 ...
- 还在手动发早安吗?教你用java实现每日给女友微信发送早安
摘要:教你如何用java实现每日给女友微信发送早安等微信信息. 本文分享自华为云社区<java实现每日给女友微信发送早安等微信信息>,作者:穆雄雄 . 前言 据说这个功能最近在抖音上很火, ...
- LiteOS:剖析时间管理模块源代码
摘要:Huawei LiteOS的时间管理模块以系统时钟为基础,分为2部分,一部分是SysTick中断,为任务调度提供必要的时钟节拍:另外一部分是,给应用程序提供所有和时间有关的服务,如时间转换.统计 ...
- 聊聊LiteOS中生成的Bin、HEX、ELF三种文件格式
摘要:我们在使用编译器在编译工程后会要求生成可执行文件,将这些文件烧录到MCU进行运行,达到我们测试和使用程序的目的,再使用工具链进行编译的时候往往生成.bin..hex ..elf ..alf等文件 ...
- 将模型转为NNIE框架支持的wk模型第一步:tensorflow->caffe
摘要:本系列文章旨在分享tensorflow->onnx->Caffe->wk模型转换流程,主要针对的是HI3516CV500, Hi3519AV100 支持NNIE推理框架的海思芯 ...
- 数字化转型鸿沟如何消除?ROMA Connect融合集成,联接企业应用现在与未来
摘要:ROMA Connect平台正在以"联接和融合"的方式,重塑传统企业上云的路径--"条条大路"通向云端. 本文分享自华为云社区<[大厂内参]第13期 ...
- 智能电视APP鲜时光,如何应用AB测试打造极致的用户观看体验?
更多技术交流.求职机会,欢迎关注字节跳动数据平台微信公众号,回复[1]进入官方交流群 数字技术的发展让智能电视普及率大幅提升,2023年智能电视的市场渗透率已超90%,与智能电视相匹配的各类应用 ...
- PPT 商务PPT 如何展示你的产品
PPT 商务PPT 如何展示你的产品 如何优雅的展示产品 如何展示互联网产品 直接产品截图,比较生硬,简单粗暴 使用场景+样机 放一个电脑或手机的外壳 如何展示产品 如何展示现实中的产品 多角度剪裁 ...