mysql decimal(6_MySQL(六) decimal数据默认处理
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(6_MySQL(六) decimal数据默认处理相关推荐
- MySQL基础回顾(六):数据查询语言DQL---select查询语句总结(篇一)
目录 先建一个数据库和若干张表 完整语法 1.基础查询 2.字段别名 3.去重 4.where子句查询 5.模糊查询 6.联表查询 7.分页和排序 8.子查询和嵌套查询 9.分组查询和having语句 ...
- php从mysql资源类型_php从mysql里读出来的数据默认什么类型?
php是弱类型语言,但是不代表没有类型,或者随便什么类型. 一个典型的例子就是从mysql数据库里读出来的数据,其类型会和数据库里定义的类型一致吗? $DB_CONN = mysql_connect( ...
- (六)大白话MySQL是如何基于冷热数据分离的方案,来优化LRU算法?
(一)大白话MySQL执行SQL的流程 (二)大白话InnoDB存储引擎的架构设计 (三)大白话MySQL Binlog是什么? (四)MySQL的Buffer Pool内存结构 (五)MySQL的B ...
- mysql decimal长度_mysql decimal类型与decimal长度用法详解
以下内容转自:http://blog.csdn.net/zhanghao143lina/article/details/53816884 三者的区别介绍 float:浮点型,含字节数为4,32bit, ...
- mysql第四篇:数据操作之多表查询
mysql第四篇:数据操作之多表查询 一.多表联合查询 #创建部门 CREATE TABLE IF NOT EXISTS dept (did int not null auto_increment P ...
- mysql unix_timestamp now() dfdfd f_数据库函数lpad的搜索结果-阿里云开发者社区
我的MYSQL学习心得(六) 原文:我的MYSQL学习心得(六) 我的MYSQL学习心得(六) 我的MYSQL学习心得(一) 我的MYSQL学习心得(二) 我的MYSQL学习心得(三) 我的MYSQL ...
- python进阶与数据操控_python进阶(mysql:表操作、数据操作、数据类型)(示例代码)...
3.mysql数据库 3.4 表和数据的基础操作 3.4.1. 创建表 create create table 表名( 字段名1 类型[(宽度) 约束条件], 字段名2 类型[(宽度) 约束条件], ...
- mysql 字段字符串转int_MySQL数据库面试题(2020最新版)(一)
作者:ThinkWon 来源:https://blog.csdn.net/ThinkWon/article/details/104778621 数据库基础知识 1. 为什么要使用数据库 数据保存在内存 ...
- MySQL 创建数据库和创建数据表
MySQL 是最常用的数据库,在数据库操作中,基本都是增删改查操作,简称CRUD. 在这之前,需要先安装好 MySQL ,然后创建好数据库.数据表.操作用户. 一.数据库操作语言 数据库在操作时,需要 ...
- decimal 整数 mysql_MySQL decimal类型
在本教程中,我们将向您介绍MySQL DECIMAL数据类型以及如何在数据库表中有效地使用它. MySQL DECIMAL数据类型简介 MySQL DECIMAL数据类型用于在数据库中存储精确的数值. ...
最新文章
- 如何赋能零售行业数字化转型? SAP从这些方向发力
- 美国任命首位首席信息安全官
- 自建html网页,幽灵自建的html5 的模板文件!
- ubuntu下mysql-python模块的安装
- Lecture 6 Order Statistics
- bokeh python_Python Bokeh数据可视化教程
- 《微积分》框架逻辑的简单理解
- 机器学习基本算法思想和步骤
- java静态成员静态代码块初始化顺序
- docker 安装oracle11g 并配置数据持久化
- PDF内嵌字体分析 - 提取的文字是乱码原因分析
- 取自开源,分享于开源 —— 利用CVE-2017-8890漏洞ROOT天猫魔屏A1
- 仿照支付宝等——自动获取短信中的验证码
- 编译时内核栈溢出:the frame size of 1928 bytes is larger than 1024 bytes
- 经典点云去噪算法总结
- 图形杂记-Decal贴花
- R语言中的并行计算实现
- 如何快速检索PDF文档中的关键词?
- java验证xml格式是否正确的是_java判断文件是否为xml格式的方法
- 微信小程序_自定义头像和昵称