MYSQL 重复使用已被删除的主键Id,查询不连续的主键id

原创
2021/09/29 16:40
阅读数 101
select id from (select id from enterprise where id <![CDATA[>]]>#{start} order by id asc) t where not exists (select 1 from enterprise where id=t.id-1) limit 1

 

否则自增会越来越大,又不能使用OPMIZE TABLE 来优化表空间

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
0 评论
0 收藏
0
分享
返回顶部
顶部