mysql - ALTER TABLE error when adding new column -


    alter table mytable add mycolumn int not null default(0) 

when doing error: #1064 - have error in sql syntax; check manual corresponds mysql server version right syntax use near '(0)' @ line 2

any idea why? thanks!

the syntax default clause accept value not expression (even constant). see http://dev.mysql.com/doc/refman/5.0/en/data-type-defaults.html:

the default value clause in data type specification indicates default value column. 1 exception, default value must constant; cannot function or expression.


concretely, have remove parenthesis:

alter table mytable add mycolumn int not null default 0 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -