mysql 数据类型

数字

类型 含义 字节
BIT[(M)] 1-64 bit个数
TINYINT[(M)] [UNSIGNED] [ZEROFILL] -128–127/0–255 1
BOOL, BOOLEAN 单元格
SMALLINT[(M)] [UNSIGNED] [ZEROFILL] -32768 to 32767/0 to 65535 2
MEDIUMINT[(M)] [UNSIGNED] [ZEROFILL] -8388608 to 8388607/0 to 16777215. 3
INT[(M)] [UNSIGNED] [ZEROFILL] -2147483648 to 2147483647/ 0 to 4294967295
INTEGER[(M)] [UNSIGNED] [ZEROFILL] 4
BIGINT[(M)] [UNSIGNED] [ZEROFILL] -9223372036854775808 to 9223372036854775807/0 to 18446744073709551615
DECIMAL[(M[,D])] [UNSIGNED] [ZEROFILL]
FLOAT[(M,D)] [UNSIGNED] [ZEROFILL] -3.402823466E+38 to -1.175494351E-38, /0, and 1.175494351E-38 to 3.402823466E+38 4
FLOAT(p) [UNSIGNED] [ZEROFILL]
DOUBLE[(M,D)] [UNSIGNED] [ZEROFILL] -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.7976931348623157E+308 8
DOUBLE PRECISION[(M,D)] [UNSIGNED] [ZEROFILL], REAL[(M,D)] [UNSIGNED] [ZEROFILL]

时间

类型 含义 字节
DATE ‘0000-00-00’ 3
TIME ‘00:00:00’ 3 bytes + fractional seconds storage
DATETIME ‘0000-00-00 00:00:00’ 5 bytes + fractional seconds storage
TIMESTAMP ‘0000-00-00 00:00:00’ 4 bytes + fractional seconds storage
YEAR 0000 1

字符串

类型 含义 字节
[NATIONAL] CHAR[(M)] [CHARACTER SET charset_name] [COLLATE collation_name] 单元格
[NATIONAL] VARCHAR(M) [CHARACTER SET charset_name] [COLLATE collation_name] 单元格 L + 1 bytes if column values require 0 − 255 bytes, L + 2 bytes if values may require more than 255 bytes
BINARY[(M)] 单元格
VARBINARY(M) 单元格
TINYBLOB 单元格
TINYTEXT [CHARACTER SET charset_name] [COLLATE collation_name] 单元格
BLOB[(M)] 单元格
TEXT[(M)] [CHARACTER SET charset_name] [COLLATE collation_name] 单元格
MEDIUMBLOB 单元格
MEDIUMTEXT [CHARACTER SET charset_name] [COLLATE collation_name] 单元格
LONGBLOB 单元格
LONGTEXT [CHARACTER SET charset_name] [COLLATE collation_name] 单元格
ENUM(‘value1’,’value2’,…) [CHARACTER SET charset_name] [COLLATE collation_name] 单元格
SET(‘value1’,’value2’,…) [CHARACTER SET charset_name] [COLLATE collation_name] 单元格