您的位置:首页 > 数据库 > MySQL

mysql二进制类型

2016-05-05 10:02 501 查看
由于之前网站使用第三方登录,QQ昵称比较特殊,所以用二进制的字段类型存储。

mysql二进制类型有:

BINARY

VARBINARY

TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB

顺便列一下各种数据类型的存储范围:

Storage Requirements for Numeric Types

Data TypeStorage Required
TINYINT
1 byte
SMALLINT
2 bytes
MEDIUMINT
3 bytes
INT
,
INTEGER
4 bytes
BIGINT
8 bytes
FLOAT(p
)
4 bytes if 0 <=
p
<= 24, 8 bytes if 25 <=
p
<= 53
FLOAT
4 bytes
DOUBLE [PRECISION]
,
REAL
8 bytes
DECIMAL(M
,
D
)
,
NUMERIC(M
,
D
)
Varies; see following discussion
BIT(M
)
approximately (
M
+7)/8 bytes

Storage Requirements for Date and Time Types

Data TypeStorage Required Before MySQL 5.6.4Storage Required as of MySQL 5.6.4
YEAR
1 byte1 byte
DATE
3 bytes3 bytes
TIME
3 bytes3 bytes + fractional seconds storage
DATETIME
8 bytes5 bytes + fractional seconds storage
TIMESTAMP
4 bytes4 bytes + fractional seconds storage

Storage Requirements for String Types

Data TypeStorage Required
CHAR(M
)
M
×
w
bytes, 0
<= M
<= 255, where
w
is the number of bytes required for the maximum-length character in the character set. SeeSection 15.2.6.7, “Physical Row Structure” for information about
CHAR
data type storage requirements for
InnoDB
tables.
BINARY(M
)
M
bytes, 0
<= M
<= 255
VARCHAR(M
),
VARBINARY(M
)
L
+ 1 bytes if column values require 0 − 255 bytes,
L
+ 2 bytes if values may require more than 255 bytes
TINYBLOB
,
TINYTEXT
L
+ 1 bytes, where
L
< 28
BLOB
,
TEXT
L
+ 2 bytes, where
L
< 216
MEDIUMBLOB
,
MEDIUMTEXT
L
+ 3 bytes, where
L
< 224
LONGBLOB
,
LONGTEXT
L
+ 4 bytes, where
L
< 232
ENUM('value1
','
value2
',...)
1 or 2 bytes, depending on the number of enumeration values (65,535 values maximum)
SET('value1
','
value2
',...)
1, 2, 3, 4, or 8 bytes, depending on the number of set members (64 members maximum)

参考:http://dev.mysql.com/doc/refman/5.7/en/data-types.html

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: