https://blog.csdn.net/kriszhang/article/details/72125203

首先设置一个变量,初始值为0:

set @r:=0;
  • 1

然后更新表中对应的ID列:

update tablename set id=(@r:=@r+1)
  • 1

如果是插入,那就找一个记录多的表t1

set @r:=0;
insert into t select @r:=@r+1 from t1 limit 0, 2000
  • 1
  • 2

@完

相关文章:

  • 2021-04-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案