In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Editor to share with you the example analysis of varchar and text in Mysql, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Varchar takes up 2 bytes for each ASCII character and only 2 bytes for a Chinese character.
Char occupies 1 byte for ASCII characters and 2 bytes for a Chinese character.
The type of Varchar is not filled with spaces, such as varchar (100), but its value is only "n", then its value is "n"
Char is different, such as char (100), whose value is "n" when in fact it is "n" in the database (there are 99 spaces after n, that is, fill it up to 100 bytes).
Because char is of fixed length, it will be much faster than varchar! But the program is a little more troublesome to deal with, using functions such as trim to remove the spaces on both sides!
Note that for char (N) / varchar (N) after encoding, N represents the maximum number of characters allowed in the current column. Not the number of bytes.
Text types can be divided into tinytext (255length), smalltext (65535), midumtext (int maximum) and longtext (long maximum).
In mysql, data of type text is different from that of varchar/char. Data of type text will be stored outside the metadata table, but varchar/char will be stored in the table data file along with other columns.
Text data types will actually greatly increase the size of database table files, so there will be some impact on physical storage. At the same time, the retrieval of text data and IO output will also increase the competition for memory.
In many cases, we recommend that text types, especially data with large length or frequent changes, be stored in other proprietary platforms, such as NOSQL.. In essence, it is not that mysql is not suitable for storing text, but in too many cases we expect mysql to provide small data query / transaction processing more efficiently.
The above is all the content of the article "sample Analysis of varchar and text in Mysql". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.