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

What are the definitions and restrictions of varchar in MySQL version

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article is to share with you about the definition and restrictions of varchar in the MySQL version. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Below version 4.0, varchar (50) refers to 50 bytes. If you store UTF8 characters, you can only store 16 characters (3 bytes each).

Version 5.0 and above, varchar (50), refers to 50 characters, which can be stored in either numeric, alphabetic or UTF8 Chinese (3 bytes each).

Storage limit

Extra bytes are required to store the length of characters: 1 byte for less than 255 and 2 bytes for greater than 255

Coding limit

Gbk: up to 2 bytes per character

Utf8: up to 3 bytes per character

Utf8mb4 takes up to 4 bytes per character, Chinese 3 bytes, and emoji emoticons 4 bytes.

Length limit

MySQL defines that the length of rows cannot exceed 65535, which limits the number of columns, such as the char (128) utf8 character set, with a maximum of 65535 / (12832) = 170Chinese characters.

These are the definitions and restrictions of varchar in the MySQL version. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please 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