What is the difference between MySQL type varchar () and text

Source: Internet
Author: User
Tags versions

The wrong answer has been adopted, misleading others.

Char Max 255 characters
varchar maximum 65,535 bytes (so, different character sets, the number of characters can be stored differently)
Text Max 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 use varchar or text
3. Can use varchar place without text

Add a point: Generally descriptive text more often, try to use text. Using text, when making a fuzzy query, does not affect the speed.


VarChar is restricted storage text unrestricted storage, that is, the text can be stored varchar not necessarily line, but varchar can store the text can certainly

In the MySQL5.0.3 and above versions, the length of the varchar data type is supported to 65535, which means that 65,532 bytes of data can be stored, and the starting and ending bits take up 3 bytes, that is, data stored in a fixed text or BLOB format in the following versions of 5.0.3 can be used in high Variable length varchar is used in the version to store

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.