Data types supported by MySQL

Source: Internet
Author: User
Tags time zones local time

MySQL Supported data Types

1 , numeric type

Integer types: TINYINT (1), SMALLINT (2), Mediumint (3), Int/integer (4), BIGINT (8)

Floating-point type: Float (4), DOUBLE (8)

Bit type: bit (M) (1~8)

For shaping data, it is supported to specify that Xi ' an is width within the parentheses following the type name.

such as int (5), which means that the numeric width is less than 5 digits before the number fills the width.

The specified width is not displayed by default to int (11), used with Zerofill: with 0 padding,

But if it is more than can be entered, such as

Auto_increment, an attribute of the shape type, a table with a maximum of one, its column is not NULL, and is defined as a primary key or a unique key.

Floats and fixed-point numbers can be represented by the type name plus (m,d):

Represents a total of M-digits (integers + decimals), where D is behind the decimal point/(precision and scale)

2 , Time type

Date: Month Date

DATETIME: Month and day, minutes and seconds

Time: Seconds

TIMESTAMP: Requires frequent insertion or update of the current system time YYYY-MM-DD HH:MM:SS (19 characters total)

Timestamp is very similar to the way DateTime is expressed, with the main difference:

(1), timestamp support time range is small, and the DateTime range is larger

(2), the first timestamp column in the table is automatically set to the system time. If you insert null in a timestamp column, the column value is automatically set to the current date and time. Inserting or updating a row, but not explicitly assigning a value to the timestamp column, automatically sets the current date and time, and when the inserted value exceeds the value range, MySQL overflows and fills with "0000-00-00 00:00:00".

(3), timestamp insert and query are affected by the local time zone, more able to reflect the actual date. DateTime can only reflect the local time zone at the time of insertion, and other time zones will have errors.

(4), the timestamp property is affected by the MySQL version and the Wu Blessing Sqlmode greatly.

The year range is (1901-2155). Use two-bit string when range (00-99) (00-69:2000-2069;70-99:1970-1999)

3 , String type

char and varchar types

Char: fixed length for the length declared when the table was created, char column removes trailing spaces

VARCHAR: variable long string, varchar reserved trailing space

Binary and varbinary types

Binary and varbinary types are similar to char and varchar, but differ in that they contain binary strings and do not contain non-binary strings.

Enum type

Enumeration type, which requires 1 bytes for 1-255 members and 2 bytes for 255-65535 members.

CREATE table T (Gender enum (' M ', ' F ')); Describes the range only between m,f.

INSERT into t values (' M '), (' L '), (' F '), (null)

Set type (non-repeating)

Similar to the enum type, it is also a string object. Set can select multiple members at a time, and enum can only select one.

Data types supported by MySQL

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.