当前位置:网站首页>MySQL - data type
MySQL - data type
2022-06-21 13:35:00 【Longbow dog learning C】
Catalog
Data type classification
There are four types
- value type
- Text binary type
- Time date
- string type

We need to understand value type What are the different allowable maximum and minimum values

Let's do some cross-border tests :
We can find out , Shaping is signed by default . So how to create unsigned ?
bit type
//bit Basic grammar bit[(M)]: Bit field type .M Represents the number of digits in each value , Range from 1 To 64. If M Be ignored , The default is 1.
ask : Why? a The corresponding value is not displayed ?
because bit When the field is displayed , Is in accordance with the ASCII The value corresponding to the code displays .
Decimal type
In numeric types , among float The type and decimal Type belongs to decimal type .
//float grammar float[(m, d)] [unsigned] : M Specify the display length ,d Specify the number of decimal places , Occupancy space 4 Bytessuch as float(4,2) The range of representation is -99.9~99.99.
We can see from the inserted values ,float It will be rounded when saving .
When float Is unsigned ,float(4,2)unsigned The scope is 0~99.99
//decimal grammar decimal(m, d) [unsigned] : Fixed-point number m Specify the length ,d Number of decimal placessuch as decimal(5,2) The range of representation is -999.99~999.99
Above ,decimal(5,2) unsigned Range of representation 0 ~ 999.99
look decimal and float Very similar , Let's see the difference between the two
String type
String types are char and varchar
//char grammar char(L): Fixed length string ,L Is the length that can be stored , Unit as character , The maximum length value can be 255
//varchar grammar varchar(L): Variable length string ,L Represents character length , Maximum length 65535 Bytes
char and varchar Compare two string types
How to choose which one to use ? Please follow the following rules
- If the data is determined to be the same length , Just use a fixed length (char), such as : Id card , cell-phone number ,md5
- If the data length changes , Just use lengthening (varchar), such as : name , Address , But you have to make sure that the longest can be saved .
- Fixed length disk space is a waste , But it's efficient .
- Longer disk space is more economical , But it's inefficient .
- The meaning of fixed length is , Directly open up the corresponding space
- The meaning of lengthening is , Without exceeding the custom scope , How much to use , How much .
Time type
There are three common dates :
- date : date 'yyyy-mm-dd' , Take up three bytes
- datetime Time date format 'yyyy-mm-dd HH:ii:ss' Indicates a range from 1000 To 9999 , Take up the octet
- timestamp : Time stamp , from 1970 Year begins yyyy-mm-dd HH:ii:ss Format and datetime Exactly the same , Occupy four bytes
We can see , The timestamp will automatically generate the current time . Next let's revise t1 Time for .
enum and set
// Both syntax enum(' Options 1',' Options 2',' Options 3',...); set(' Option value 1',' Option value 2',' Option value 3', ...);
边栏推荐
- 如何使用搜索引擎?
- AGCO AI frontier promotion (6.21)
- 居家辦公初體驗之新得分享| 社區征文
- Kotlin - i/o flow
- May the mountains and rivers be safe
- PingCAP 入选 2022 Gartner 云数据库“客户之声”,获评“卓越表现者”最高分
- 处理接口幂等性的两种常见方案
- Flink CDC MongoDB Connector 的实现原理和使用实践
- 7. pointer
- Is it safe to open a securities account by downloading the app of qiniu business school? Is there a risk?
猜你喜欢
![[deeply understand tcapulusdb technology] tmonitor system upgrade](/img/ec/bbfb7e2f19a94b69ec0a6092fd3032.png)
[deeply understand tcapulusdb technology] tmonitor system upgrade

Unbounded territory won the title of innovative brand of digital culture industry in 2022

如何阅读AI顶会论文?

Isn't this another go bug?

Work content of service governance

Set up ZABBIX monitoring and email alarm

Eureka's timedsupersortask class (periodic task with automatic interval adjustment)
MySQL constraints (descriptions of various conditions when creating tables)

TOOD: Task-aligned One-stage Object Detection

Map collection traversal, adding, replacing and deleting elements
随机推荐
实践 DevOps 时,可能面临的六大挑战
seaborn绘图风格的设置
Implementation principle and application practice of Flink CDC mongodb connector
scrapy_redis分布式爬虫
Apache shardingsphere 5.1.2 release | new driving API + cloud native deployment to create a high-performance data gateway
SCCM creates a client collection based on the installed app and periodically pushes application updates
Unbounded territory won the title of innovative brand of digital culture industry in 2022
基于STM32电压检测和电流检测
修修补补一时爽,果断重构有担当——聊聊CRM分布式缓存优化
【深入理解TcaplusDB技术】Tmonitor后台一键安装
Test the interface between app and wechat applet
还在用generator生成xxx管理系统的CRUD代码?来看看我是怎么写的
Kotlin - sequence sequence
【深入理解TcaplusDB技术】Tmonitor系统升级
1. memory partition model
Are you still using generator to generate crud code of XXX management system? Let's see what I wrote
Six possible challenges when practicing Devops
Interpretation of tamigou project: 34% equity transfer of Jining Huayuan Project Management Co., Ltd
uva11300
5. array











