mysql ID有重复值后设置主键

select @t:=0;
update tbl_order set a=(@t:=@t+1);

alter table tbl_order add primary key(id);
alter table tbl_order change id id int(11) not null auto_increment;

 

你可能感兴趣的:(id,主键)