MySQL:一位的最小数据类型 [英] MySQL: Smallest datatype for one bit

查看:285
本文介绍了MySQL:一位的最小数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想向表中添加一列,其中包含两个值之一:1或0。

I would like to add a column to the table which contains either of two values: 1 or 0.

存储数据的最小数据类型MySQL?

What would be the smallest datatype to store the data in MySQL?

A TINYINT(1)可以包含 -127 127

推荐答案

http:// dev .mysql.com / doc / refman / 5.0 / en / storage-requirements.html

BOOL作为TINYINT存储在MySQL中,

BOOL is stored in MySQL as TINYINT which would take 1 full byte

http ://dev.mysql.com/doc/refman/5.0/en/other-vendor-data-types.html

一点(1)通常也会占用1个字节,但如果单个记录中有多个位,则它们将存储在同一个字节中,每个字节最多可存储8个。

A bit(1) would normally also take 1-byte but if there are multiple bits in a single record, then they get stored in the same byte, up to 8 per byte.

这篇关于MySQL:一位的最小数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆