MySQL自动增量列跳了10-为什么? [英] MySQL autoincrement column jumps by 10- why?

查看:90
本文介绍了MySQL自动增量列跳了10-为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个表,在这些表中我创建了一个对象ID为Int或Bigint,在两种情况下,它们似乎都会自动递增10(即,第一个插入是对象ID 1,第二个插入是对象ID 11) ,第三个是对象ID 21,依此类推).两个问题:

I have a couple tables in which I created an object ID as either an Int or Bigint, and in both cases, they seem to autoincrement by 10 (ie, the first insert is object ID 1, the second is object ID 11, the third is object ID 21, etc). Two questions:

  1. 为什么要这么做?

  1. Why does it do that?

有问题吗?

推荐答案

检查自动增量的种子值未设置为10.

Check to see the seed value of the autoincrement isn't set to 10.

您可以通过以下方式进行检查:

You can check by:

SELECT Auto_increment FROM information_schema.tables WHERE table_name='the_table_you_want';

如其他地方所述,您可以使用系统变量@@ set_auto_increment_increment进行更改

As noted elsewhere you can change by using the system variable @@set_auto_increment_increment

SET @@auto_increment_increment=1;

如果您想以一个数字以外的数字开头这些值,则可以执行以下操作:

If you want to start the values at a number other than one you can go:

ALTER TABLE tbl AUTO_INCREMENT = 100;

这篇关于MySQL自动增量列跳了10-为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆