71

再谈MySQL auto_increment空洞问题 - 简书

 6 years ago
source link: https://www.jianshu.com/p/369559f399d0?
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
在项目中时常会有这种需求,用户通过第三方系统登录时如果尚未注册,则自动给用户注册,注册过的用户自动登录。有时候图省事可能就直接INSERT INTO user ON DUPLICAET KEY UPDATE...一句 SQL 解决了,功能都正常,问题就是如果用户表中有auto_increment字段,则会导致auto_increment字段产生间隙问题,一段时间后会发现用户ID会经常出现不连...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK