enum('yes', 'no') vs tinyint - 使用哪一个? [英] enum('yes', 'no') vs tinyint -- which one to use?

查看:31
本文介绍了enum('yes', 'no') vs tinyint - 使用哪一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

保存真/假值的字段的最佳做法是什么?

What's the best practice for fields that hold true/false values?

这样的列可以定义为 enum('yes','no') 或 tinyint(1).一个比另一个更好/更快吗?

Such columns can be defined as enum('yes','no') or as tinyint(1). Is one better/faster than the other?

使用 enum('1','0') 与 enum('yes','no') 更好吗(即,它是否将 'yes' 或 'no' 作为字符串写入每一行,所以数据库存储大小变大了)?

Is it better to use enum('1','0') vs. enum('yes','no') (i.e., does it write 'yes' or 'no' as a string to every row so the database storage size gets bigger)?

推荐答案

另外,ENUM 是一个非标准的 MySql 扩展.你应该避免它,特别是如果你能以标准的方式获得相同的结果.

Also, ENUM is a non-standard MySql extension. You should avoid it, especially if you can achieve the same results in a standard way.

这篇关于enum('yes', 'no') vs tinyint - 使用哪一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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