mysql怎么改成自动添加(AUTO INCREMENT)
就是我开始设置的是id varchar(5) not null;
然后告诉我不需要弄成00001那样的,只要1、2、3这样就够了,所以我想直接自动添加。于是想改成id int auto increment;但是不知道怎么改。。求助各位!
自增字段必然是主键,所以需要添加主键信息
-
SQL code
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
alter table tbname modify id int auto_increment primary key;
探讨
引用:
alter table tbname modify id int auto_increment primary key;
和zuoxingyu2012一样,回答对我很有帮助,问题解决了,顺便说一下,我是在linux下操作,权限也一直是root权限。
顺便问一下,现在这样的话,自增就是从1起吧?