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
精彩评论