创建表格时添加:

create table table1(id int auto_increment primary key,...)



创建表格后添加:

删除原有主键:

ALTER TABLE `table_name` DROP `id`;

alter table table1 add id int auto_increment primary key 自增字段,一定要设置为primary key.


例子

alter table tablename drop column id;
alter table tablename add id mediumint(8) not null primary key auto_increment first;



方法二:

alter table tablename auto_increment=0

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-22
  • 2022-12-23
  • 2021-08-14
猜你喜欢
  • 2021-08-16
  • 2022-03-07
  • 2022-12-23
  • 2021-10-29
  • 2022-12-23
相关资源
相似解决方案