Mysql decimal(m,d)的说明
mysql 说明 Decimal
2023-06-13 09:12:27 时间
大家好,又见面了,我是你们的朋友全栈君。
看了一些博客,觉得很多都是复制的,不如自己亲测一篇:
create table decimal_test(
id int auto_increment PRIMARY key,
score decimal(5,2) -- 取值范围是 -999.99 到 999.99
);
-- 整数的位数必须小于等于m-d,不然报错。小数的位数可以大于d位。多出d位时会做四舍五入,截取到d位。
-- 以上均不包括小数点、符号的位数。数字的总长度是m位,保存后的小数位最多是d位。如果保存后是整数,小数位不会补0。
-- 以下测试版本是5.7.14
select * from decimal_test;
-- 正数:
insert into decimal_test(score) VALUES(1.23); -- 1.23
insert into decimal_test(score) VALUES(123.45); -- 123.45
insert into decimal_test(score) VALUES(123.455); -- 123.46
insert into decimal_test(score) VALUES(123.451); -- 123.45
insert into decimal_test(score) VALUES(123.451123); -- 123.45
insert into decimal_test(score) VALUES(12345.451123); -- Out of range value for column 'score'
insert into decimal_test(score) VALUES(9999.451123); -- Out of range value for column 'score'
insert into decimal_test(score) VALUES(999.451123234324); -- 999.45
insert into decimal_test(score) VALUES(999.999999999); -- Out of range value for column 'score'
insert into decimal_test(score) VALUES(999.99123); -- 999.99
-- 负数:
insert into decimal_test(score) VALUES(-1.23); -- -1.23
insert into decimal_test(score) VALUES(-12.34); -- -12.34
insert into decimal_test(score) VALUES(-123.45); -- -123.45
insert into decimal_test(score) VALUES(-999.45); -- -999.45
insert into decimal_test(score) VALUES(-12343); -- Out of range value for column 'score'
insert into decimal_test(score) VALUES(12343); -- Out of range value for column 'score'
insert into decimal_test(score) VALUES(1234); -- Out of range value for column 'score'
insert into decimal_test(score) VALUES(123); -- 123
insert into decimal_test(score) VALUES(-123); -- -123
insert into decimal_test(score) VALUES(-999.99); -- -999.99
insert into decimal_test(score) VALUES(-9990.99); -- Out of range value for column 'score'
insert into decimal_test(score) VALUES(-1234.99); -- Out of range value for column 'score'
insert into decimal_test(score) VALUES(-1234); -- Out of range value for column 'score'
select VERSION() ; -- 5.7.14
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/160867.html原文链接:https://javaforall.cn
相关文章
- mysql decimal 空,MySQL DECIMAL数据类型
- MySQL如何高效存储图片数据(mysql怎么存储图片)
- MySQL中的整数函数使用说明(mysql整数函数)
- MySQL 中的加法运算函数使用说明(mysql加法函数)
- 分片技术:MySQL 打造分布式系统(mysql分片技术)
- MYSQL存储过程:以实例说明(mysql存储过程例子)
- 本以高端技术推出MySQL收费版本(mysql收费版)
- 据库快速掌握MySQL查询连接数据库技巧(mysql查询连接数)
- MySQL字段解析:帮助理解表结构(mysql字段说明)
- 使用 CI 框架和 MySQL 打造高效Web应用(ci框架mysql)
- MySQL驱动:64位系统最佳选择(mysql驱动64位)
- 深入浅出,让你彻底了解MySQL数据库的索引优化技巧(mysql数据库的索引)
- MySQL参数详解,让你更加了解Mysql参数定义及优化。(mysql参数定义)
- MySQL使用详解:全面学习MYSQL技术(mysql大全)
- MySQL中使用游标的详细说明(mysql 声明游标)
- MySQL数据类型长度:探索与调整(mysql数据类型长度)
- MySQL中substr函数的使用说明(mysql中substr)
- MySQL的IF语句使用说明(mysql中if的意思)
- MySQL中如何设置bit类型数据字段(mysql中bit设置)
- 从cmd输入命令快速登陆MySQL数据库(cmd如何登陆mysql)
- 数据用CMD命令行快速删除MySQL数据(cmd mysql删除)
- 深入MySQL一月内掌握数据库操作技巧(mysql 一月)
- MYSQL收费了 了解MySQL开源版的最新政策(mysql不再免费了吗)
- MySQL下载版本说明选择最适合你的版本(mysql下载版本说明)
- MySQL下载只提供32位版本(mysql下载只有32位)