MySQL alter table命令不起作用

时间:2011-11-01 11:56:10

标签: mysql sql

我正在尝试向现有用户表添加一列,但它不起作用。我明白了:

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”,我做错了什么? 感谢

2 个答案:

答案 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;