在使用Mysql 时,时常需要生成记录编号,此方法适用于Mysql8.0及以上版本
UPDATE 当前表名
JOIN (
SELECT id,
ROW_NUMBER() OVER (ORDER BY id) AS new_recNO
FROM 当前表名
) t
ON 当前表名.id = t.id
SET 当前表名.recNO = t.new_recNO;
sqlite 请参考 Sqlite 记录号(RecNo)的生成及更新到数据表_数据库表中的recno-CSDN博客