当前位置:网站首页>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', ...);
边栏推荐
- Isn't this another go bug?
- Consultation: what kind of securities company is micro securities? Is it safe to open an account?
- IMU selection, calibration error analysis, AHRS integrated navigation
- Kubernetes快速實戰與核心原理剖析
- Pretraining Weekly No. 50: No Decode converter, neural prompt search, gradient Space reduction
- Application configuration management, basic principle analysis
- 【深入理解TcaplusDB技术】TcaplusDB构造数据
- Is the live interactive function of the applet running in the app?
- Highly available configuration of database (MySQL)
- Six possible challenges when practicing Devops
猜你喜欢

分布式事务,原理简单,写起来全是坑

Reading notes on how to connect the Internet ADSL

塔米狗 热门资讯:厦门产权交易中心再创第一次!

3D slicer import label and view label

用时间戳优化 TCP 实践

SCCM creates a client collection based on the installed app and periodically pushes application updates

【深入理解TcaplusDB技术】TcaplusDB构造数据

Setting of Seaborn drawing style

Matplotlib drawing tips

这不会又是一个Go的BUG吧?
随机推荐
Artifacial Intelligent Project
如何使用搜索引擎?
Turn to the countdown for coupon issuance! First look at the rules of interstellar pocket donation
PHP uses grafika to synthesize pictures and generate poster images
Voltage detection and current detection based on stm32
Numpy | insert variable length character array test OK
1. memory partition model
Using slurm cluster computing node debugger in vscode
Summary of the latest remote deployment O & M tools
Display all indexes of a table in Oracle
Two common schemes for handling interface idempotence
《网络是怎么样连接的》读书笔记 - ADSL
处理接口幂等性的两种常见方案
Eureka的TimedSupervisorTask类(自动调节间隔的周期性任务)
3. operator
seaborn绘图风格的设置
17 commonly used o & M monitoring systems
The new plan for national treasures - the exclusive digital collection of the four museums is coming!
居家辦公初體驗之新得分享| 社區征文
【深入理解TcaplusDB技术】Tmonitor后台一键安装











