开发者

How can i create boolean column and assign value 1 when creating/altering a column of a mysql table?

I'm trying something like this =>

alter table tablenam开发者_开发百科e modify columnname "boolean" default 1 NOT NULL;

Which is the correct format to create boolean column ?


ALTER TABLE tablename CHANGE columnname columnname BOOLEAN DEFAULT '1' NOT NULL

Is this what you are after?


alter table tablename modify columnname boolean default true NOT NULL;

Don't put quotes around boolean.

I tested this on a column that was int and it worked.


instead of boolean use TINYINT(1). This is preferred on InnoDB database engine

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜