DECIMAL Data Type

本文详细解析了 MySQL 中 DECIMAL(M,D) 和 NUMERIC(M,D) 类型的存储方式及计算方法。这两种类型具有完全相同的精度 M 位,并探讨了不同数字组合下所需字节数的具体情况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

In MySQL, DECIMAL(M,D) and NUMERIC(M,D) are the same, and both have a precision of exactly M digits.

Leftover Digits    Number of Bytes
0             0
12            1
34            2
56            3
79            4

 For example,

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.

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.

转载于:https://www.cnblogs.com/zengkefu/p/5618994.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值