如果你会用PHP的话,装一个phpmyadmin。 创建一张test表把字段a设为int型非空并且为自增长。 create table test (a int not null auto_increment,primary key(a)); 在现有表基础上增加一列id为自增长。 alter table tests add id int auto_increment,add primary key(id);
mysql中在创建自增加字段的时候,必须要把这个字段设置为主键 还有一个注意的是,如果你是在现在表的基础上增加ID字段的话,你还必须确保表中没有主键 就是说你用alter table tests add id int auto_increment,add primary key(id);之前 应该用一句alter table tests drop primary key; 以防止重复定义主键
创建一张test表把字段a设为int型非空并且为自增长。
create table test (a int not null auto_increment,primary key(a));
在现有表基础上增加一列id为自增长。
alter table tests add id int auto_increment,add primary key(id);
还有一个注意的是,如果你是在现在表的基础上增加ID字段的话,你还必须确保表中没有主键
就是说你用alter table tests add id int auto_increment,add primary key(id);之前
应该用一句alter table tests drop primary key;
以防止重复定义主键