我正在尝试向现有用户表添加一列,但它不起作用。我明白了:
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
这是我的命令:
root@localhost:test> alter table users add column users_is_active tinyint(3) not null unsigned default 0 after users_id;
除非我没有正确拼写“not null”,我做错了什么? 感谢
答案 0 :(得分:19)
alter table users添加列users_is_active tinyint(3)not null unsigned default 0 after users_id;
TINYINT(3) UNSIGNED
是类型。 NOT NULL
不属于TINYINT(3)
和UNSIGNED
。而是说TINYINT(3) UNSIGNED NOT NULL
(等等)。
答案 1 :(得分:1)
将unsigned
移近tinyint
:
alter table users
add column users_is_active tinyint(3) unsigned not null default 0
after users_id;