Types of char and varchar for MySQL data types

Source: Internet
Author: User

In MySQL database system, char and varchar are very common, and they are two very similar, are used to save relatively short string, such as saving the article title, message, email, user name and so on. The main difference between the two is the storage method:

The Char column length is the length that is declared when the table is created and is fixed, and the length is limited to between 0 and 255. Generally in the database design, the user to save passwords, names, IP information, because the basic length are fixed, with this type is more appropriate.

The value in the varchar column is a variable-length string, and the length is 0-255, extending to 65535 after 5.0.3.

When the query displays the data, char deletes the space at the end of the string (just the tail), while varchar retains the spaces completely. This way we do not need to trim the trailing spaces when we display the char type string.

Brother even education for you to solve more it technology problems.

Types of char and varchar for MySQL data types

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.