[转帖]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
DECIMAL
columns
The declaration syntax for a DECIMAL
column is DECIMAL(
. The ranges of values for the arguments are as follows:M
,D
)
M
is the maximum number of digits (the precision). It has a range of 1 to 65.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
.
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 ...
随机推荐
- 从C++CLI工程的依赖库引用问题看.Net加载程序集机制
问题 最近在为某第三方MFC项目写C++/CLI工程插件时遇到了如下一个问题: MFC的工程不允许把.Net的依赖程序集放到执行程序的目录(防止影响其稳定性),依赖库只能放到非执行程序子目录的其他目录 ...
- CSS之动画
一.动画 动画类型 CSS3 可以创建动画,它可以取代许多网页动画图像.Flash 动画和 JavaScript 实现的效果. transform属性可以定义一些主要的动画属性, translate: ...
- JavaImprove--Lesson01--枚举类,泛型
一.枚举 认识枚举类 枚举是一种特殊的类 枚举的格式: 修饰符 enmu 枚举类名{ 名称1,名称2: 其它成员 } //枚举类 public enum A { //枚举类的第一列必须是罗列枚举 ...
- 华为云分布式云原生UCS,助力MetaERP构建企业级高可用分布式业务
本文分享自华为云社区<华为云分布式云原生UCS,助力MetaERP构建企业级高可用分布式业务>,作者:云容器大未来. 引言 华为云最近成为<Forrester Wave: Multi ...
- 昇腾CANN 7.0 黑科技:大模型训练性能优化之道
本文分享自华为云社区<昇腾CANN 7.0 黑科技:大模型训练性能优化之道>,作者: 昇腾CANN . 目前,大模型凭借超强的学习能力,已经在搜索.推荐.智能交互.AIGC.生产流程变革. ...
- DTSE Tech Talk | 第11期:深入浅出畅谈华为云低时延直播技术
摘要:详解华为云低时延直播在时延.首屏.卡顿率等体验的优化方案,及如何快速接入方法. 本文分享自华为云社区<DTSE Tech Talk | 第11期:深入浅出畅谈华为云低时延直播技术>, ...
- iOS App的打包和上架流程
转载:iOS App的打包和上架流程 - 掘金 1. 创建账号 苹果开发者账号几种开发者账号类型 个人开发者账号 费用:99 美元/年(688.00元) 协作人数:仅限开发者自己 不需要填写公司的 ...
- PPT 商务PPT怎么做
商务报告:公司专属PPT模板怎么做? 通过LOGO 提取主色调 搜集相关元素 通过LOGO 提取主色调 搜集相关元素 下载图片使用 建立版面
- vue 基础学习 一
1. vue 使用快速入门三步走 (1) 新建 HTML 页面,引入 Vue.js文件 <!DOCTYPE html> <html> <head> <meta ...
- 微服务系列-如何使用 RestTemplate 进行 Spring Boot 微服务通信示例
概述 下面我们将学习如何创建多个 Spring boot 微服务以及如何使用 RestTemplate 类在多个微服务之间进行同步通信. 微服务通信有两种风格: 同步通讯 异步通信 同步通讯 在同步通 ...