当前位置:网站首页>MySQL data type learning notes
MySQL data type learning notes
2022-07-01 06:35:00 【Small dollar】
There are five types of plastic surgery
int Type account 4 A byte a byte eight bits is 2 Of 32 bits
int(5) Indicates that the width is 5, But if it goes beyond 5 It doesn't matter
int(5)zerofill Time dissatisfaction 5 Bit will be used automatically 0 fill , At the same time, it becomes an unsigned number
8.0.17 When creating a table, indicate that the field is not indicating the number of words ,zerofil Indicates the width , Unsigned words are 0-4294967295
Applicable scenario
tinyint: System settings 0-100 When
smallint: The system sets the total inventory 65535 Unsigned maximum
mediumint: Passenger flow at the station 16 million
int: Big enough , It is often used, such as the product number
bigint: Large website hits
Floating point type
Floating point numbers and fixed-point numbers are used in larger scenarios than integers
float: Single precision 4
double: Double precision 8
Floating point problem unsigend The space doesn't get bigger .mysql A special case , Therefore, it is generally not increased in order to make it larger unsigend float(m,d)m Is the sum of decimal and integer digits ,d It's a decimal place , This representation is called a nonstandard type
Use doube and float When calculating data, there will be errors if a certain number is equal to a certain number , Try not to use the floating-point type = Judge whether the data are equal , that mysql Is there a precise data type ? There are fixed-point numbers
Fixed-point number
decimal(m,d) Total storage space used m+2 individual , Floating point numbers represent a wider range of values . The bottom layer uses strings to store data, so it is accurate enough
decimal If the precision and scale are not specified, the default is (10,0) There are no decimals by default , If it exceeds the specified range, it will be rounded off
mysql 8.0 The precision and index of the back will be added
If in the default decimal If you add decimals, you will be rounded off
A type of
1-64 Bit storage
Is not specified m The default is 1 position , Default 1 Bit to store a value
insert into my(f1) values(2) An error will be reported here , Because decimal 2 Is to store two digits 10,
When looking up the stored value in the command line, I found that 16 Base display , If you want to specify the hexadecimal display, then bin(F1) This shows
If you want to display in decimal select f1 +0, f2 + 0 from my
Because of the operation with the decimal system, the display result is also decimal
Explanation of date time type
year Occupy 1 The storage space of bytes is relatively small , General writing 4 There is a difference between two digits , At the same time, four digits must be enclosed in single quotation marks
date type 3 Bytes yyyy-mm-dd, You want the current system time to be now() perhaps currentdate()
The number type can also , You can also write numeric types , There are implicit transformations
time 3 Bytes Minutes and seconds hh-mm-ss Anterior band D For days
12:10 Indicates hours and minutes
values(2 12:30:29)2 God 12 Hours 30 branch 29 second
datetime Occupy 8 Bytes Specific date Minutes and seconds
Used a lot
timestap Less bytes But the storage range is limited 1970 To 2038 year
At the same time, the time zone will change , The stored is converted into milliseconds according to the time zone , The number of milliseconds will also change when the time zone changes , When sorting by month, day, hour, minute and second timestap It'll be faster
Text string type
char
char Specify a character by default , If specified 5 Can accommodate 5 Chinese characters
And when the storage quantity is 5 When , Storage 3 The two empty spaces on the right of the are automatically filled with spaces . Automatically remove the blank space when searching .
Put in ‘12 ’ When , If you calculated the length of this string, it would have been 4 But the result is 2, In fact, two spaces are automatically removed
varchar The number must be specified , A Chinese character has three bytes varchar(20)5.0 The above version refers to 20 Characters , So you can save it 20 The Chinese characters
Wise remark of an experienced person : Specifically, if you store very short messages , Like house number varchar Use char
Fixed length use uuid For storage , Use when you need to change back and forth varchar. Specifically, the storage engine is needed to connect .innodb Use varchar
text type
tinytexy:
text:
mediumtext:
longtext:
There's no fixed length , Primary keys cannot be used , The actual storage type is not too large. It is recommended to use char perhaps varchar
Enumeration type .
Provide values when creating tables , When inserting, you can only add , Case ignored . You can also use an index to call enumeration elements , such as 123, You can also join null
set type : The number of members is 64 You can choose more than one
Binary type
json type
Type of space
summary : If the integer is int type , decimal decimal, date datetime(m,d) Specify scale and precision . If the string is non negative, it is automatically defined as unsigned, Decimal type is decimal, If more than decimal The storage range of decimal and integer are stored separately , If the storage length is equal, use char, If not, use varchar, If the length exceeds 5000 Then use text Storage
边栏推荐
- C语言课设学生选修课程系统(大作业)
- 【Unity Shader 消融效果_案例分享】
- 【#Unity Shader#自定义材质面板_第一篇】
- 请求模块(requests)
- 10 golang operator
- Notes on probability theory
- [unity shader stroke effect _ case sharing first]
- ManageEngine Zhuohao helps you comply with ISO 20000 standard (IV)
- [automatic operation and maintenance] what is the use of the automatic operation and maintenance platform
- Requests module (requests)
猜你喜欢

SQL语句

Async and await
![阿里OSS Postman Invalid according to Policy: Policy Condition failed: [“starts-with“, “$key“, “test/“]](/img/3c/7684b7c594f7871471f89007294703.png)
阿里OSS Postman Invalid according to Policy: Policy Condition failed: [“starts-with“, “$key“, “test/“]

Picture server project test

High order binary balanced tree

C language course set up salary management system (big homework)
![[ManageEngine Zhuohao] what is network operation and maintenance management and what is the use of network operation and maintenance platform](/img/a4/b1476515260e3af0ca0dcc031deb98.png)
[ManageEngine Zhuohao] what is network operation and maintenance management and what is the use of network operation and maintenance platform

下载外文期刊的方法

谷粒商城-环境(p1-p27)
![[ManageEngine Zhuohao] helps Julia college, the world's top Conservatory of music, improve terminal security](/img/fb/0a9f0ea72efc4785cc21fd0d4830c2.png)
[ManageEngine Zhuohao] helps Julia college, the world's top Conservatory of music, improve terminal security
随机推荐
嵌入式系统
C语言课设物业费管理系统(大作业)
[network security tool] what is the use of USB control software
Interview questions for HW (OD) post
证券类开户有什么影响 开户安全吗
C language course set up library information management system (big homework)
C语言课设职工信息管理系统(大作业)
Student attendance system for C language course (big homework)
自开发软件NoiseCreater1.1版本免费试用
数据库笔记
SQL语句
mysql数据类型学习笔记
Mongodb: I. what is mongodb? Advantages and disadvantages of mongodb
Detailed steps for installing redis on Windows system
Database notes
[unity shader custom material panel part II]
H5网页判断是否安装了某个APP,安装则跳转未安装则下载的方案总结
C language course design student information management system (big homework)
Three minutes to quickly understand the whole process of website development
C语言课设图书信息管理系统(大作业)