Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of varchar and text in Mysql

2025-01-17 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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report