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
This article uses an example to illustrate the us...
Abstract: This article will demonstrate how to se...
What should I do if MySQL fails to connect to the...
1. Start the Docker container Start a new Docker ...
Table of contents 1. New II. Modification element...
Introduction To put it simply, tcpdump is a packe...
The value of the background property in CSS backg...
Download the zip installation package: Download a...
Load balancing is a commonly used device in serve...
As shown below: //Query the year and month of the...
This article mainly explains how to deploy Elasti...
Introduction to MySQL Window Functions MySQL has ...
In a table, you can define the color of the lower...
*Create a page: two input boxes and a button *Cod...
1. Preparation 1.1 harbor download harbor downloa...