失败插入时auto_increment gap

时间:2018-06-14 13:39:26

标签: mysql mysql-workbench

目前,我们正在使用Python和MySQL。在Python脚本中,我们使用innodb_autoinc_lock_mode库将数据写入数据库。我们对几个表有约束,因此不会将冗余数据写入数据库,但是,如果发生失败的插入,auto_increment值会在row_id之间创建一个间隙。因此表中的主键是row_id,使用auto_increment约束设置。

我们尝试使用const ref = firebase.database().ref('Users'); ref.child(this.state.username).once("value").then(function(snapshot) { console.log(snapshot.val().title); }); 但没有运气。我们在Windows 7上本地运行MySQL80实例。

当insert语句失败时,是否有更好的方法来解决这个问题?理想情况下,我们希望没有差距。

0 个答案:

没有答案