当前位置:网站首页>MySQL learning notes - data type (numeric type)
MySQL learning notes - data type (numeric type)
2022-07-04 15:13:00 【Murshaw 756】
Catalog
4.2 Floating point numbers VS Fixed-point number
One 、 Data type refinement
1、MySQL Data types in



2、 Integer types
2.1 Type introduction

Example :

8.0 There will be (), for example tinyint(4), It represents the number of digits occupied by the plus symbol , and -128 To +127 Namely 4 position . If you use unsigned UNSIGNED, Namely 3.8.0 It is not recommended to specify the width in the future .
2.2 Optional attribute


1、 Do not apply ZEROFILL when , It doesn't matter whether you specify the display width or not . Use ZEROFILL when , Specify the display width as n, When insert Insufficient value for n position , Just use 0 fill , If exceeded n position , You don't have to .
2、 When using ZEROFILL when , Automatically add UNSIGNED
2.3 Use scenarios
2.4 How to choose

3、 Floating point type
3.1 Type introduction

3.2 Data accuracy description

Example : 
1、 Use FLOAT and DOUBLE when , Better not add M and D.
2、 In programming , If floating point numbers are used , Pay special attention to the error , Because floating point numbers are inaccurate , So try to avoid using = To determine whether two floating-point numbers are equal . stay MySQL Inside , With more precise data types :DECIMAL;
4、 Fixed point number type
4.1 Type introduction
Use DECIMAL when , General plus M and D, If not , Default (10,0).


4.2 Floating point numbers VS Fixed-point number
The advantage of floating-point number over fixed-point number is that when the length is certain , Floating point type has a wide range of values , But not exactly , It is suitable for large range of values , It can also tolerate small errors in scientific computing scenarios ( Like computational chemistry 、 Molecular modeling 、 Flow mechanics, etc )、
The value range of fixed-point number type is relatively small , But accuracy , There is no error , It is suitable for scenes that require high accuracy ( For example, scenarios involving amount calculation )
4.3 Experience in development

5、 A type of

CREATE TABLE test_bit1{
f1 BIT,f2BIT(5); //f1 The default binary digit is 1, So only for 0 and 1,f2 Digit is 5, So you can save 0-31
}

边栏推荐
- Kubernets Pod 存在 Finalizers 一直处于 Terminating 状态
- Redis哨兵模式实现一主二从三哨兵
- Ali was laid off employees, looking for a job n day, headhunters came bad news
- Preliminary exploration of flask: WSGI
- Yyds dry goods inventory # solve the real problem of famous enterprises: continuous maximum sum
- Ffmpeg Visual Studio development (IV): audio decoding
- PXE网络
- 直播预告 | PostgreSQL 内核解读系列第二讲:PostgreSQL 体系结构
- 自动控制原理快速入门+理解
- Leetcode 1200 minimum absolute difference [sort] the way of leetcode in heroding
猜你喜欢

如何搭建一支搞垮公司的技术团队?

Ranking list of databases in July: mongodb and Oracle scores fell the most

力扣刷题01(反转链表+滑动窗口+LRU缓存机制)

智能客服赛道:网易七鱼、微洱科技打法迥异

Halcon knowledge: NCC_ Model template matching
Redis哨兵模式实现一主二从三哨兵

03-存储系统

直播预告 | PostgreSQL 内核解读系列第二讲:PostgreSQL 体系结构

They are all talking about Devops. Do you really understand it?

深度学习 网络正则化
随机推荐
韩国AI团队抄袭震动学界!1个导师带51个学生,还是抄袭惯犯
UFO: Microsoft scholars have proposed a unified transformer for visual language representation learning to achieve SOTA performance on multiple multimodal tasks
web聊天室实现
这几年爆火的智能物联网(AIoT),到底前景如何?
MySQL组合索引(多列索引)使用与优化案例详解
Halo effect - who says that those with light on their heads are heroes
数据库函数的用法「建议收藏」
Deep learning network regularization
Huawei cloud database DDS products are deeply enabled
Comment configurer un accord
Preliminary exploration of flask: WSGI
[local differential privacy and random response code implementation] differential privacy code implementation series (13)
Leetcode 1200 minimum absolute difference [sort] The Path of leetcode for heroding
go-zero微服务实战系列(九、极致优化秒杀性能)
Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
Weibo and Huya advance into interest communities: different paths for peers
03-存储系统
[differential privacy and data adaptability] differential privacy code implementation series (XIV)
[learning notes] matroid
IO flow: node flow and processing flow are summarized in detail.
