MySQL Workbench:尝试为表创建布尔字段
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9382508/
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
MySQL Workbench: trying to create a boolean field for a table
提问by ziiweb
I'm trying to create a new column as boolean type, but I can't find it in the list..any help?
我正在尝试创建一个布尔类型的新列,但我在列表中找不到它..有什么帮助吗?
5.2.37 and ubuntu 11.10
5.2.37 和 Ubuntu 11.10
回答by Widor
There is no such thing as a 'boolean' in MySql unfortunately.
不幸的是,MySql 中没有“布尔值”这样的东西。
I think you need tinyint(1)
.
我认为你需要tinyint(1)
.
This question has more: Which MySQL data type to use for storing boolean values
这个问题有更多:用于存储布尔值的 MySQL 数据类型
回答by Pieter Van Keymeulen
Skip the workbench and use the command line
跳过工作台并使用命令行
alter table my_table add column my_column BOOLEAN;
回答by Rakesh
To Create a Boolean Columnin Table with default false
在表中创建布尔列,默认值为 false
ALTER TABLE table_name ADD field_name tinyint(1);
if default true
如果默认为真
ALTER TABLE table_name ADD field_name tinyint(0);