create table decimal_test(
id int auto_increment PRIMARY key,
score decimal(5,2) -- 取值范围是 -999.99 到 999.99
);

decimal(M,D)M=整数位+小数位
-- 整数的位数必须小于等于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.6.30

MySQL(二) decimal数据默认处理的更多相关文章

  1. 分布式计算(二)使用Sqoop实现MySQL与HDFS数据迁移

    近期接触了一个需求,业务背景是需要将关系型数据库的数据传输至HDFS进行计算,计算完成后再将计算结果传输回关系型数据库.听到这个背景,脑海中就蹦出了Sqoop迁移工具,可以非常完美的支持上述场景. 当 ...

  2. MySQL行(记录)的详细操作一 介绍 二 插入数据INSERT 三 更新数据UPDATE 四 删除数据DELETE 五 查询数据SELECT 六 权限管理

    MySQL行(记录)的详细操作 阅读目录 一 介绍 二 插入数据INSERT 三 更新数据UPDATE 四 删除数据DELETE 五 查询数据SELECT 六 权限管理 一 介绍 MySQL数据操作: ...

  3. Spring Boot 揭秘与实战(二) 数据存储篇 - MySQL

    文章目录 1. 环境依赖 2. 数据源3. 脚本初始化 2.1. 方案一 使用 Spring Boot 默认配置 2.2. 方案二 手动创建 4. 使用JdbcTemplate操作5. 总结 4.1. ...

  4. DF学Mysql(二)——数据表的基本操作

    1.创建数据表 先使用“USE <数据库名>”指定在哪个数据库中操作 CREATE TABLE <表名> ( 字段1 数据类型 [列级别约束条件] [默认值], 字段2 数据类 ...

  5. hadoop项目实战--ETL--(二)实现自动向mysql中添加数据

    四 项目开发 1 创建数据库db_etl,新建两张表user 和oder.表结构如第一部分图所示. 2 编写python脚本,实现自动向mysql中插入数据. 新建python 项目,目录结构如下图 ...

  6. [转] MySql 优化 大数据优化

    一.我们可以且应该优化什么? 硬件 操作系统/软件库 SQL服务器(设置和查询) 应用编程接口(API) 应用程序 ------------------------------------------ ...

  7. redis作为mysql的缓存服务器(读写分离,通过mysql触发器实现数据同步)

    一.redis简介Redis是一个key-value存储系统.和Memcached类似,为了保证效率,数据都是缓存在内存中.区别的是redis会周期性的把更新的数据写入磁盘或者把修改操作写入追加的记录 ...

  8. [转]mysql导入导出数据中文乱码解决方法小结

    本文章总结了mysql导入导出数据中文乱码解决方法,出现中文乱码一般情况是导入导入时编码的设置问题,我们只要把编码调整一致即可解决此方法,下面是搜索到的一些方法总结,方便需要的朋友. linux系统中 ...

  9. Win7安装mysql数据库、修改默认密码

    学习和使用myslq数据库半年时间,mysql对于每一个开发人员都不会陌生.今天对电脑重装系统,为了方面测试在个人PC上安装了mysql数据库.以一下是整个安装过程. 一.下载mysql 1.首先需要 ...

随机推荐

  1. luogu 3380

    树状数组套权值线段树 #include <iostream> #include <cstdio> #include <algorithm> #include < ...

  2. [NOI2010]超级钢琴 倍增

    [NOI2010]超级钢琴 倍增 题面 暴力:枚举区间丢入堆\(O(n^2logn)\) 正解:考虑每次枚举和弦起点\(s\),那么以\(s\)为起点的和弦为\(sum[t]-sum[s](s+L-1 ...

  3. shell 边边角角

    [Shell学习笔记] 数组.关联数组和别名使用 Linux中bash脚本数组和字典使用举例 Linux Shell 通配符.元字符.转义符使用实例介绍

  4. H-Fashion in Berland

    #include <bits/stdc++.h> using namespace std; int a[1005]; int main() { int n; scanf("%d& ...

  5. ELF格式说明

    ELF file header (ELF文件头) /* The ELF file header. This appears at the start of every ELF file. */ #de ...

  6. C++标准库分析总结(四)——<Vector、Array、Forward_list设计原则>

    本节主要总结标准库Vector和Array的设计方法和特性以及相关迭代器内部特征 1.Vector 1.1 Vector 内部实现 Vector是自增长的数组,其实在标准库中没有任何一种容器能原地扩充 ...

  7. 5.linux 软件安装的三种方法

      一.linux 操作系统中 软件的分类 以及软件的安装     vmtools  调用了perl语言写的安装脚本去进行内核的升级安装  ./ xxxxx        源码包安装软件:GNU  使 ...

  8. Selenium: 利用select模块操作下拉框

    在利用selenium进行UI自动化测试过程中,经常会遇到下拉框选项,这篇博客,就介绍下如何利用selenium的Select模块来对标准select下拉框进行操作... 首先导入Select模块: ...

  9. 在从myql服务器上 取消主从关系和重新构建主从关系

    取消主从关系 mysql -uroot -p mysql>show slave status\G; 查看主库是否为之前的ip mysql>change master to master_h ...

  10. http://www.cnblogs.com/sealedbook/p/6194047.html

    http://www.cnblogs.com/sealedbook/p/6194047.html