MySQL data types _ MySQL

Source: Internet
Author: User
MySQL data types: bitsCN.com
MySQL has three main data types: Text, numbers, and date/time. Text: data type description CHAR (size) stores fixed-length strings (can contain letters, numbers, and special characters ). Specify the length of the string in parentheses. It can contain a maximum of 255 characters. VARCHAR (size) stores variable-length strings (including letters, numbers, and special characters ). Specify the maximum length of the string in parentheses. It can contain a maximum of 255 characters. Note: If the value length is greater than 255, it is converted to the TEXT type. TINYTEXT stores strings with a maximum length of 255 characters. TEXT is a string of up to 65,535 characters. BLOB is used for BLOBs (Binary Large OBjects ). Stores up to 65,535 bytes of data.
MEDIUMTEXT stores strings with a maximum length of 16,777,215 characters. MEDIUMBLOB is used for BLOBs (Binary Large OBjects ). Stores up to 16,777,215 bytes of data. LONGTEXT stores strings with a maximum length of 4,294,967,295 characters. LONGBLOB is used for BLOBs (Binary Large OBjects ). Stores up to 4,294,967,295 bytes of data. ENUM (x, y, z, etc.) allows you to enter a list of possible values. You can list a maximum of 65535 values in the ENUM list. If no inserted value exists in the list, a null value is inserted. Note: These values are stored in the order you entered. Possible values can be entered in this format: ENUM ('X', 'y', 'z') SET is similar to ENUM. SET can contain up to 64 list items, however, SET can store more than one value. Number type: data type description TINYINT (size)-128 to 127 general. 0 to 255 unsigned *. Specify the maximum number of digits in parentheses. SMALLINT (size)-32768 to 32767. 0 to 65535 unsigned *. Specify the maximum number of digits in parentheses. MEDIUMINT (size)-8388608 to 8388607 normal. 0 to 16777215 unsigned *. Specify the maximum number of digits in parentheses. INT (size)-2147483648 to 2147483647. 0 to 4294967295 unsigned *. Specify the maximum number of digits in parentheses. BIGINT (size)-9223372036854775808 to 9223372036854775807. 0 to 18446744073709551615 unsigned *.

Specify the maximum number of digits in parentheses. FLOAT (size, d) is a small number with a floating decimal point. Specify the maximum number of digits in parentheses. Specify the maximum number of digits to the right of the decimal point in parameter d. DOUBLE (size, d) is a large number with a floating decimal point. Specify the maximum number of digits in parentheses. Specify the maximum number of digits to the right of the decimal point in parameter d. DECIMAL (size, d) is the DOUBLE type stored as a string. a fixed DECIMAL point is allowed. * These integer types have additional options UNSIGNED. Generally, integers can be negative or positive. If the UNSIGNED attribute is added, the range starts from 0, instead of a negative number. Date type: data type description DATE () Date. Format: YYYY-MM-DD note: the supported range is a combination of dates and times from '2017-01-01 'to '2017-12-31' DATETIME. Format: YYYY-MM-DD HH: MM: SS note: Supported range is from '2017-01-01 00:00:00 'to '2017-12-31 23:59:59' TIMESTAMP () * TIMESTAMP. The TIMESTAMP value is stored in the Unix epoch ('2017-01-01 00:00:00 'UTC) to date. Format: YYYY-MM-DD HH: MM: SS note: the supported range is from '2017-01-01 00:00:01 'UTC to '2017-01-09 03:14:07' utc time () TIME. Format: HH: MM: SS note: the supported range is from '-838: 59: 59' to '2017: 59: 59' YEAR () 2-digit or 4-digit year. Note: values allowed in 4-digit format: 1901 to 2155. Value range: 70 to 69, which indicates that the value ranges from 1970 to 2069. * Even if DATETIME and TIMESTAMP return the same format, they work in different ways. In INSERT or UPDATE queries, TIMESTAMP automatically sets itself to the current date and time. TIMESTAMP also accepts different formats, such as YYYYMMDDHHMMSS, YYMMDDHHMMSS, YYYYMMDD, or YYMMDD.
BitsCN.com

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.