Question: What is the difference between int(1) and tinyint(1)?With a design like this, I would never write int(1) anyway. I checked and found that after setting the storage type in MySQL, the storage is fixed-length, that is, We know that the int type occupies 4 bytes and tinyint occupies 1 byte. int(1) and int(4) are the same in terms of their length and storage method. The only difference is the displayed length. However, a parameter must be set: if Note that the number in parentheses after the numeric type does not indicate the length but the display width, which is different from the meaning of the number after varchar and char. That is to say In summary, no matter how many numbers are in the brackets of the integer data type, the storage space occupied is the same. tinyint 1 byte smallint 2 bytes MEDIUMINT 3 bytes Obviously, Summarize:
The above summary is a bit messy. Here is a brief summary:There is no difference between tinyint(1) and tinyint(3). They both occupy one byte and have the same storage range. Int(1) and tinyint(1), if sufficient, tinyint 1 byte smallint 2 bytes MEDIUMINT 3 bytes int 4 bytes BIGINT 8 bytes. However, the 5 in varchar(5) limits the number of characters that can be stored, regardless of their value (regardless of Chinese, English, numbers, etc.). The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Issues with Rancher deployment and importing K8S clusters
>>: Detailed explanation of TypeScript's basic types
Docker only maps ports to IPv6 but not to IPv4 St...
Step 1: Enter the directory: cd /etc/mysql, view ...
Table of contents Install: 1. Basic use of firewa...
During the installation of Ubuntu 18, the mmx64.e...
Table of contents 1. Core 1. Get the Dom node 2. ...
Definition of Generics // Requirement 1: Generics...
Cause of the problem: At first, the default yum s...
Preface This article summarizes some implementati...
Detailed explanation of the solution to garbled c...
Preface: In some previous articles, we often see ...
If MySQL version 5.0 already exists on the machin...
1. Update the yum source The PostgreSQL version o...
Nowadays, many websites do not allow direct copyin...
INSERT INTO hk_test(username, passwd) VALUES (...
Implement Nginx load balancing based on Docker ne...