就是我开始设置的是id varchar(5) not null;
然后告诉我不需要弄成00001那样的,只要1、2、3这样就够了,所以我想直接自动添加。于是想改成id int auto increment;但是不知道怎么改。。求助各位!

解决方案 »

  1.   

    alter table tabname MODIFY id int AUTO_INCREMENT;
      

  2.   

    报错了。。
    Incorrect table definition; there can be only one auto column and it must be defined as a key
      

  3.   

    自增字段必然是主键,所以需要添加主键信息
    mysql> alter table b modify bid int AUTO_INCREMENT primary key; 
    Query OK, 0 rows affected (0.36 sec) 
    Records: 0  Duplicates: 0  Warnings: 0
      

  4.   

    是用root用户操作的提示是不是权限的问题。
      

  5.   

    alter table tbname modify id int auto_increment primary key;
      

  6.   

    alter table tabname MODIFY id int AUTO_INCREMENT;
      

  7.   

    和zuoxingyu2012一样,回答对我很有帮助,问题解决了,顺便说一下,我是在linux下操作,权限也一直是root权限。
    顺便问一下,现在这样的话,自增就是从1起吧?