MySQL Notes: Data types

Source: Internet
Author: User

One, integer

Integer and Smallint,mysql are supported in standard SQL to extend the tinyint, mediumint, and bigint.

MySQL supports specifying the display width of the data type, such as int (8), which specifies that the display width of type int is 8.

MySQL supports bool and Boolean in the SQL standard, but is converted to tinyint (1).

Second, floating point and fixed-point number

MySQL uses floating-point float, double, and fixed-point decimal to represent decimals.

MySQL supports specifying the precision and scale of floating and fixed-point numbers, precision refers to the total length of the data, and the scale refers to the length after the decimal point. For example, decimal (M,D) specifies a precision of M and a scale of D.

The storage space for a decimal is determined by its precision, and defaults to a 10-bit integer if not specified.

Third, date and time

Year, date, time, datetime, and timestamp represent dates and times.

In addition to TIMESTAMP using Current_time or Now () to get the current system time, TIMESTAMP uses current_timestamp, NULL, or does not specify a value to get the current system time.

Four, string

Both char and varchar types Specify a maximum length at creation time, for example, char (32) specifies that the maximum length of the string is 32. VarChar can dynamically allocate space within the maximum length.

TEXT can only hold character data, including Tinytext, TEXT, Mediumtext, and Longtext.

Enum and set are predefined list of strings, where the strings in the enum list are numbered in the order they are declared. Enum can only select single values from the list, and set can select multiple values.

Five or two binary

Both binary and barbinary types specify a maximum length at creation time, such as binary (32) specifying the maximum length of the binary number is 32. The varbinary can dynamically allocate space within the maximum length.

The bit type also specifies the maximum length when it is created, but the difference is that the maximum length supported by bit is 64.

BLOBs, Tinyblob, Mediumblob, and Longblob types are used to hold large data volumes of binary data, such as cases.

MySQL Notes: 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.