TINYINT与ENUM(0,1)对于MySQL中的布尔值 [英] TINYINT vs ENUM(0, 1) for boolean values in MySQL

查看:175
本文介绍了TINYINT与ENUM(0,1)对于MySQL中的布尔值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哪一个更好,Tinyint在MyISAM表和MySQL 5.1中有0和1值或ENUM 0,1?

Which one is better, Tinyint with 0 and 1 values or ENUM 0,1 in MyISAM tables and MySQL 5.1?

推荐答案

您可以使用 BIT(1) -overview.htmlrel =noreferrer> mysql 5.1参考。我不会推荐 enum tinyint(1)
as bit(1 )只需要1位用于存储布尔值,而 tinyint(1)需要8位。

You can use BIT(1) as mentioned in mysql 5.1 reference. i will not recommend enum or tinyint(1) as bit(1) needs only 1 bit for storing boolean value while tinyint(1) needs 8 bits.

这篇关于TINYINT与ENUM(0,1)对于MySQL中的布尔值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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