mysql-field type

Source: Internet
Author: User

Start by counting all the tables to see

Number Type

Column type The amount of storage needed
TINYINT 1 bytes
SMALLINT 2 bytes
MEDIUMINT 3 bytes
INT 4 bytes
INTEGER 4 bytes
BIGINT 8 bytes
FLOAT(X) 4 if x < = 24 or 8 If < = X < = 53
FLOAT 4 bytes
DOUBLE 8 bytes
DOUBLE PRECISION 8 bytes
REAL 8 bytes
DECIMAL(M,D) MByte ( D +2, if M < D )
NUMERIC(M,D) MByte ( D +2, if M < D )

date and Time type

Column type The amount of storage needed
DATE 3 bytes
DATETIME 8 bytes
TIMESTAMP 4 bytes
TIME 3 bytes
YEAR 1 bytes

String Type
Column type The amount of storage needed
CHAR(M) MBytes1 <= M <= 255
VARCHAR(M) L+ 1 bytes, in this L <= M and1 <= M <= 255
TINYBLOB,TINYTEXT L+ 1 bytes, in this L < 2 ^ 8
BLOB,TEXT L+ 2 bytes, in this L < 2 ^ 16
MEDIUMBLOB,MEDIUMTEXT L+ 3 bytes, in this L < 2 ^ 24
LONGBLOB,LONGTEXT L+ 4 bytes, in this L < 2 ^ 32
ENUM(‘value1‘,‘value2‘,...) 1 or 2 bytes, depending on the number of enumeration values (max. 65535)
SET(‘value1‘,‘value2‘,...) 1,2,3,4 or 8 bytes, depending on the number of members of the collection (up to 64 members)

Field type:

TINYINT [(M)] [UNSIGNED] [zerofill]


A very small integer. The signed range is 128 to 127, the unsigned range is 0 to 255.

SMALLINT [(M)] [UNSIGNED] [zerofill]

A small integer. The signed range is 32768 to 32767, the unsigned range is 0 to 65535.

Mediumint [(M)][UNSIGNED][  Zerofill]

A medium-sized integer. The signed range is 8388608 to 8388607, the unsigned range is 0 to 16777215.

INT [(M)] [UNSIGNED] [zerofill]

A normal size integer. The signed range is 2147483648 to 2147483647, the unsigned range is 0 to 4294967295.

INTEGER [(M)] [UNSIGNED] [zerofill]

This is a synonym for int.

BIGINT [(M)] [UNSIGNED] [zerofill]

A large integer. The signed range is 9223372036854775808 to 9223372036854775807, the unsigned range is 0 to 18446744073709551615.

FLOAT [(m,d)] [zerofill]

A small (single-precision) floating-point number. cannot be unsigned. The allowable values are -3.402823466E+38 to -1.175494351e-38,0 and 1.175494351E-38 to 3.402823466E+38. M is the number of digits that display the width and d is a decimal. Float with no parameters or a parameter with <24 represents a single precision floating point number.

DOUBLE [(m,d)] [zerofill]

A normal-size (double-precision) floating-point number. cannot be unsigned. The allowed values are -1.7976931348623157E+308 to -2.2250738585072014E-308,
0 and 2.2250738585072014E-308 to 1.7976931348623157E+308.

DOUBLE PRECISION [(m,d)] [zerofill] REAL [(m,d)] [zerofill]

These are double synonyms.

DECIMAL [(m[,d][zerofill]

A floating-point number that is uncompressed (unpack). cannot be unsigned. Behaves like a char column: "Uncompressed" means that the number is stored as a string, and each bit of the value uses one character.

[zerofill]

This is a synonym for decimal.

A date. The scope of support is ' 1000-01-01 ' to ' 9999-12-31 '. MySQL Displays the date value in ' YYYY-MM-DD ' format, but allows you to assign a value to the date column using a string or a number.

Datetime

A date and time combination. The scope of support is ' 1000-01-01 00:00:00 ' to ' 9999-12-31 23:59:59 '. MySQL displays datetime values in ' yyyy-mm-dd HH:MM:SS ' format, but allows you to assign a value to a datetime column using a string or a number.

TIMESTAMP [(M)]

A time stamp. The range is ' 1970-01-01 00:00:00 ' to sometime in 2037. MySQL Displays the timestamp value in Yyyymmddhhmmss, Yymmddhhmmss, YYYYMMDD, or YYMMDD format, depending on whether M is 14 (or omitted), 12, 8, or 6, However, you are allowed to assign a value to the timestamp column using a string or a number. A timestamp column is useful for recording the date and time of an insert or update operation, because if you do not assign it yourself, it is automatically set to the date and time of the most recent operation. You can set it to the current date and time by assigning it a null value.

A time. The range is ' -838:59:59 ' to ' 838:59:59 '. MySQL displays the time value in ' HH:MM:SS ' format, but allows you to assign a value to the time column using a string or a number.

 Year [(2|4)]

A 2-or 4-digit year (the default is 4-bit). The allowed values are 1901 to 2155, and 0000 (4-bit year format), if you use 2 bits, 1970-2069 (70-69). MySQL Displays the year value in yyyy format, but allows you to assign a string or numeric value to the year column. (The year type is the new type in MySQL3.22.) )

CHAR [BINARY]

A fixed-length string that, when stored, always fills the right to the specified length with a space. The range of M is 1 ~ 255 characters. When the value is retrieved, the trailing space is deleted. Char values are sorted and compared in a case-insensitive manner based on the default character set, unless binary keywords are given. National char (short form NCHAR) is an ANSI SQL way to define a CHAR column that should use the default character set. This is the default for MySQL. Char is an abbreviation for character.

[National] VARCHAR [BINARY]

A variable-length string. Note: When the value is stored, the trailing spaces are deleted (this differs from the ANSI SQL specification). The range of M is 1 ~ 255 characters. The varchar values are sorted and compared in a case-insensitive manner based on the default character set, unless the binary keyword value is given. See 7.7.1 Implicit column specifies the change. VARCHAR is an abbreviation for character varying.

A blob or text column with a maximum length of 255 (2^8-1) characters

TEXT

A blob or text column with a maximum length of 65535 (2^16-1) characters

A blob or text column with a maximum length of 16777215 (2^24-1) characters

A blob or text column with a maximum length of 4294967295 (2^32-1) characters

ENUM ('value1','value2'

Enumeration. A string object that has only one value, selected from the Value list ' value1 ', ' value2 ', ..., or null. An enum can have a maximum of 65535 different values.

SET ('value1','value2'

A collection. A string object that can have 0 or more values, each of which must be from the Value list ' value1 ', ' value2 ', ... Elected. A set can have a maximum of 64 members.

mysql-field type

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.