Learning notes: MySQL String type

Source: Internet
Author: User

String type a) char and varchar

1. You need to specify the length of the character, the length of the char is the length of the character, and the length of the varchar is the length of the byte

2. The length specified in char is the actual length occupied, and the length specified by varchar is only a range, so varchar also takes 1-2 bytes to store the string exactly how many bytes it has. And the character that can be actually stored in varchar is related to encoding (UTF8 encoding 20,000, GBK encoding more than 30,000)

3.varchar more flexible storage footprint, but char is more efficient

4. If the length of the string is fixed known, use char, if the length of the string is variable, use varchar

b) Text:

Text type, which is similar to varchar, except that there is no need to specify a length, where longtext that there is no limit to the text.

c) Enum:

Enumeration type, similar to radio! The actual storage is the location of the original option, the location is replaced by 1,2,3,4, in theory can represent up to 65,535 options

D) Set:

collection type, similar to multi-select! The actual storage is also the location of the original selection, the location is replaced with 1,2,4,8, and then the location of all the options are added, theoretically can represent up to 64 multi-option

e) binary, varbinary, blob:

Binary text type, which is the char, varchar, and text of the byte stream, rarely used in actual projects

Learning notes: MySQL String type

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.