In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This post is about what type of content mysql stores text in. Xiao Bian thinks it is quite practical, so share it for everyone to make a reference. Let's follow the editor and have a look.
When mysql stores text, it uses the following three types.
Char has a fixed length, varchar and text have variable lengths. (char may have wasted space, the string length is not enough, then the empty string is supplemented with spaces)
Char and varchar can be set to default values, text has no default value.
Char and varchar are defined to specify length, text is usually defined without specifying length, you can calculate it yourself.
CHAR and VARCHAR types
CHAR(M) is a fixed-length string that is defined with a specified string column length. When saving, fill spaces to the right to reach the specified length. M represents the length of the column, ranging from 0 to 255 characters.
For example, CHAR(4) defines a fixed-length list of characters that contains a maximum of 4 characters. When a CHAR value is retrieved, trailing spaces are removed.
VARCHAR(M) is a variable-length string, where M represents the length of the largest column, and M ranges from 0 to 65535. The maximum actual length of VARCHAR is determined by the size of the longest line and the character set used, while the actual space occupied is the actual length of the string plus 1.
For example, VARCHAR(50) defines a string with a maximum length of 50, and if the inserted string has only 10 characters, the actual string stored is 10 characters and a string ending character. VARCHAR retains trailing spaces when values are saved and retrieved.
TEXT type
The TEXT column holds non-binary strings, such as article content, comments, and so on. When saving or querying values for TEXT columns, trailing spaces are not removed.
There are four types of TEXT: TINYTEXT, TEXT, MEDIUMTEXT and LONGTEXT. Different TEXT types have different storage spaces and data lengths.
TINYTEXT represents a TEXT column with a length of 255 (28-1) characters.
TEXT represents a TEXT column with a length of 65535 (216-1) characters.
MEDIUMTEXT represents a TEXT column of length 16777215 (224-1) characters.
LONGTEXT represents a TEXT column of length 4294967295 or 4GB (232-1) characters.
Thank you for reading! About mysql storage text with what type to share here, I hope the above content can be of some help to everyone, so that everyone can learn more knowledge. If you think the article is good, you can share it so that more people can see it!
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.