2011-11-01 204 views
4

我正在尝试将列添加到现有的用户表中,但它不起作用。我得到:MySQL alter table命令不起作用

ERROR 1064 (42000): 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 'unsigned default 0 after users_id' at line 1 

这里是我的命令:

[email protected]:test> alter table users add column users_is_active tinyint(3) not null unsigned default 0 after users_id; 

,除非我并没有说明“不空”正确,我在做什么错? 由于

+1

你能试换不空和无符号彼此? – spicavigo

回答

19

ALTER TABLE用户添加列users_is_active TINYINT(3)不为空的无符号值0 users_id后;

TINYINT(3) UNSIGNED是类型。 NOT NULL不属于TINYINT(3)UNSIGNED之间。相反,说TINYINT(3) UNSIGNED NOT NULL(等)。

1

移动unsigned接近tinyint

alter table users 
    add column users_is_active tinyint(3) unsigned not null default 0 
    after users_id;