In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces what is the difference between tinyint (1) and tinyint (4) in Mysql. It has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.
1. The difference between varchar (M) and numeric type tinyint (M)
String type: for varchar (M), M is the maximum string that can be stored in a field, that is, the length of the field. According to the setting, when you insert a value that exceeds the length of the field setting, you are likely to receive an error prompt, and if you are not prompted, the inserted data may also be automatically truncated to accommodate the predefined length of the field. Anything like varchar (5) means that the length of the string it stores cannot exceed 5.
Numeric column type: its length modifier indicates the maximum width and has nothing to do with the physical storage of the field, that is, the storage range is-128to127when tinyint (1) and tinyint (4) are signed (zero to 255without symbols).
Note: the signed default range (- 128-127), the default length is 4.
The unsigned default range (0,255), and the default length is 3.
If zerofill is used, when the actual length does not reach the specified display length, it will be preceded by 0.
In the data type of mysql, tinyin is related to whether it is signed or not, and the range of signed values is-128 to 127. Without a symbol, it is 0x255. The number in parentheses after the tinyint has nothing to do with the stored value, but in some cases it has something to do with the width of the display.
2 Test
What happens when you set the length of a string type name field to more than 5?
What happens when the (signed) age field of type tinyint is not set in the range (- 128? 127)?
1 bytes = 8 bit, the maximum length of data that a byte can represent is 2 to the eighth power of 11111111 in a computer.
-128 to 127
1.BIT [M]
Bit field type, M represents the number of digits for each value, ranging from 1 to 64. If M is ignored, the default is 1.
2.TINYINT [(M)] [UNSIGNED] [ZEROFILL] M defaults to 4
A very small integer. The signed range is-128 to 127. The unsigned range is 0 to 255.
3. BOOL,BOOLEAN
Is a synonym for TINYINT (1). The Zero value is considered false. A non-zero value is regarded as true.
4.SMALLINT [(M)] [UNSIGNED] [ZEROFILL] M defaults to 6
A small integer. The signed range is-32768 to 32767. The unsigned range is 0 to 65535.
5.MEDIUMINT [(M)] [UNSIGNED] [ZEROFILL] M defaults to 9
A medium-sized integer. The signed range is-8388608 to 8388607. The unsigned range is 0 to 16777215.
6. INT [(M)] [UNSIGNED] [ZEROFILL] M defaults to 11
An integer of normal size. The signed range is-2147483648 to 2147483647. The unsigned range is 0 to 4294967295.
7.BIGINT [(M)] [UNSIGNED] [ZEROFILL] M defaults to 20
Large integers. The signed range is-9223372036854775808 to 9223372036854775807. The unsigned range is 0 to 18446744073709551615.
Note: M here does not represent the specific length stored in the database, used to mistakenly think that int (3) can only store 3-length numbers, int (11) will store 11-length numbers, this is a big mistake.
Thank you for reading this article carefully. I hope the article "what is the difference between tinyint (1) and tinyint (4) in Mysql" shared by the editor will be helpful to you. At the same time, I hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.