MySQL 查询“ALTER TABLE test_posts ADD sticky boolean NOT NULL default = false” = error

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2444129/
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 15:31:48  来源:igfitidea点击:

query " ALTER TABLE test_posts ADD sticky boolean NOT NULL default = false" = error

sqlmysqlalter-table

提问by William

Whats wrong with my query?

我的查询有什么问题?

 ALTER TABLE test_posts ADD sticky boolean NOT NULL default = false 

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=false' at line 2

#1064 - 你的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取在第 2 行的“=false”附近使用的正确语法

回答by Phil Ross

You need to remove the =:

您需要删除=

ALTER TABLE test_posts ADD sticky boolean NOT NULL default false 

回答by Chandru

This SQL command should work:

这个 SQL 命令应该可以工作:

ALTER TABLE test_posts ADD sticky bit NOT NULL default 'false'