mysql二进制类型

由于之前网站使用第三方登录,QQ昵称比较特殊,所以用二进制的字段类型存储。

mysql二进制类型有:

BINARY

VARBINARY

TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB

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

Storage Requirements for Numeric Types

Data Type

Storage Required

TINYINT

1 byte

SMALLINT

2 bytes

MEDIUMINT

3 bytes

INTINTEGER

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 Type

Storage Required Before MySQL 5.6.4

Storage Required as of MySQL 5.6.4

YEAR

1 byte

1 byte

DATE

3 bytes

3 bytes

TIME

3 bytes

3 bytes + fractional seconds storage

DATETIME

8 bytes

5 bytes + fractional seconds storage

TIMESTAMP

4 bytes

4 bytes + fractional seconds storage

Storage Requirements for String Types

Data Type

Storage 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

TINYBLOBTINYTEXT

L + 1 bytes, where L < 28

BLOBTEXT

L + 2 bytes, where L < 216

MEDIUMBLOBMEDIUMTEXT

L + 3 bytes, where L < 224

LONGBLOBLONGTEXT

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

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )

Twitter的分布式自增ID算法snowflake (Java版)

概述分布式系统中,有一些需要使用全局唯一ID的场景,这种时候为了防止ID冲突可以使用36位的UUID,但是UUID有一些缺点,首先他相对比较长,另外UUID一般是无序的。有些时候我们希望能使用一种简单一些的ID,并且希望ID能够按照时间有序生成。而twitter的snowflake解决了这种需求,最初Twitter把存储系统从MySQL迁移