MySQL 正确/错误值的适当数据字段类型?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2989281/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 16:13:18  来源:igfitidea点击:

Appropriate data field type for true/false value?

mysqlintegerstoragetinyintdatafield

提问by Industrial

What's the most appropriate (read least data consuming) data field to store a true/false/1/0 value in a mySQL database?

在 mySQL 数据库中存储 true/false/1/0 值的最合适(读取最少数据消耗)数据字段是什么?

I have previously used a one character long tinyint, but I am not sure if it's the best solution?

我以前使用过一个字符长的 tinyint,但我不确定它是否是最好的解决方案?

Thanks!

谢谢!

回答by Bella

tinyint(1)

Is basically aliased from the BOOL data type so it is fine.

基本上是 BOOL 数据类型的别名,所以很好。

See here

看这里

In addition, this has already been covered here:

此外,这里已经涵盖了这一点:

Which MySQL data type to use for storing boolean values

用于存储布尔值的 MySQL 数据类型