What is the difference between mysql-type varchar () and text?

Source: Internet
Author: User

The wrong answer is also accepted, misleading.

Char cannot exceed 255 characters
Varchar can contain a maximum of 65535 bytes. Therefore, the number of characters stored in different character sets is different)
Text cannot exceed 65535 characters

1)
Varchar l + 1 byte, where L <= M and 0 <= M <= 65535
Text l + 2 bytes, where L <216
2)
1. Try to use varchar
2. More than 255 bytes can only be used with varchar or text
3. text is not used in varchar scenarios.

Note: When there are many descriptive texts, try to use text. Text does not affect the speed of fuzzy search.


Varchar is a restricted storage of unlimited text storage, that is, the varchar that can be stored by text is not necessarily a line, but the text that can be stored by varchar is certainly

In MySQL 5.0.3 and later versions, the length of the varchar data type can reach 65535, that is, 65532 bytes of data can be stored, and the start and expires bits occupy 3 bytes. That is to say, in versions earlier than 5.0.3, data stored in fixed TEXT or BLOB formats can be stored using varchar with Variable Length in later versions.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.