MySQL basics: MySQL column type-string

Source: Internet
Author: User

MySQL column type: integer http://blog.csdn.net/jk110333/article/details/9342283

MySQL column type -- time and date http://blog.csdn.net/jk110333/article/details/9342319

· Char

This is a synonym for char (1.

· [National] varchar (M) [Binary]

Variable-length string.MMaximum column length.MThe range is 0 to 65,535. (The maximum actual length of a varchar is determined by the maximum row size and the character set used. MaxValidLength is 65,532 bytes ).

Note:MySQL 5.1 complies with standard SQL specifications and does not delete trailing spaces of varchar values.

Varchar is short for varying.

The binary attribute is short for Binary checking rules for the character set of a specified column. Sorting and comparison are based on numeric character values.

When varchar is saved, it uses a prefix of one or two bytes plus data. If the length declared by the varchar column is greater than 255, the length prefix is two bytes.

· Binary (M)

The binary type is similar to the char type, but stores binary byte strings instead of non-binary strings.

· Varbinary (M)

The varbinary type is similar to the varchar type, but stores binary byte strings instead of non-binary strings.

· Tinyblob

Blob column with a maximum length of 255 (28-1) bytes.

· Tinytext

The maximum length of a text column is 255 (28-1) characters.

· Blob [(M)]

Blob column with a maximum length of 65,535 (216-1) bytes.

Optional length of this type.M. If given, MySQL creates the column as the smallest but sufficient to accommodateMThe Blob type of the byte length value.

· Text [(M)]

A text column with a maximum length of 65,535 (216-1) characters.

Optional LengthM. MySQL creates the smallest column but is sufficient to accommodateMThe text type of the character length value.

· Mediumblob

Blob column with a maximum length of 16,777,215 (224-1) bytes.

· Mediumtext

A text column with a maximum length of 16,777,215 (224-1) characters.

· Longblob

A blob column with a maximum length of 4,294,967,295 or 4 GB (232-1) bytes. Maximum number of longblob ColumnsValidThe length (allowed) depends on the maximum size of the package configured in the Client/Server protocol and the available memory.

· Longtext

A text column with a maximum length of 4,294,967,295 or 4 GB (232-1) characters. Maximum Value of the longtext ColumnValidThe length (allowed) depends on the maximum size of the package configured in the Client/Server protocol and the available memory.

· Enum ('Value1','Value2',...)

Enumeration type. There can be only one value string, from the value column'Value1','Value2',..., Null or special ''is selected. The enum column can have a maximum of 65,535 distinct values. The enum value is represented by an integer internally.

· Set ('Value1','Value2',...)

One setting. A String object can have zero or multiple values. Each value must come from the column value'Value1','Value2',... The set column can have a maximum of 64 members. The set value is represented by an integer internally.

Differences between char and varchar

Enumeration type

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.