<small id='HHWmJ'></small><noframes id='HHWmJ'>

      <i id='HHWmJ'><tr id='HHWmJ'><dt id='HHWmJ'><q id='HHWmJ'><span id='HHWmJ'><b id='HHWmJ'><form id='HHWmJ'><ins id='HHWmJ'></ins><ul id='HHWmJ'></ul><sub id='HHWmJ'></sub></form><legend id='HHWmJ'></legend><bdo id='HHWmJ'><pre id='HHWmJ'><center id='HHWmJ'></center></pre></bdo></b><th id='HHWmJ'></th></span></q></dt></tr></i><div id='HHWmJ'><tfoot id='HHWmJ'></tfoot><dl id='HHWmJ'><fieldset id='HHWmJ'></fieldset></dl></div>

    1. <legend id='HHWmJ'><style id='HHWmJ'><dir id='HHWmJ'><q id='HHWmJ'></q></dir></style></legend>
        <bdo id='HHWmJ'></bdo><ul id='HHWmJ'></ul>

    2. <tfoot id='HHWmJ'></tfoot>

      如何在 MySQL 中重置 AUTO_INCREMENT

      时间:2023-08-20
      <tfoot id='d30vp'></tfoot>

    3. <legend id='d30vp'><style id='d30vp'><dir id='d30vp'><q id='d30vp'></q></dir></style></legend>
            <bdo id='d30vp'></bdo><ul id='d30vp'></ul>

              <small id='d30vp'></small><noframes id='d30vp'>

                <tbody id='d30vp'></tbody>
              <i id='d30vp'><tr id='d30vp'><dt id='d30vp'><q id='d30vp'><span id='d30vp'><b id='d30vp'><form id='d30vp'><ins id='d30vp'></ins><ul id='d30vp'></ul><sub id='d30vp'></sub></form><legend id='d30vp'></legend><bdo id='d30vp'><pre id='d30vp'><center id='d30vp'></center></pre></bdo></b><th id='d30vp'></th></span></q></dt></tr></i><div id='d30vp'><tfoot id='d30vp'></tfoot><dl id='d30vp'><fieldset id='d30vp'></fieldset></dl></div>

                本文介绍了如何在 MySQL 中重置 AUTO_INCREMENT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                如何重置字段的AUTO_INCREMENT?

                我希望它再次从 1 开始计数.

                I want it to start counting from 1 again.

                推荐答案

                您可以通过以下方式重置计数器:

                You can reset the counter with:

                ALTER TABLE tablename AUTO_INCREMENT = 1
                

                对于 InnoDB,您不能将 auto_increment 值设置为小于或等于到目前的最高指数.(引用自 ViralPatel):

                For InnoDB you cannot set the auto_increment value lower or equal to the highest current index. (quote from ViralPatel):

                请注意,您不能将计数器重置为小于或等于的值到任何已经使用过的.对于 MyISAM,如果该值小于大于或等于当前 AUTO_INCREMENT 中的最大值列,该值将重置为当前最大值加一.为了InnoDB,如果该值小于当前的最大值列,没有错误发生,当前序列值没有改变.

                Note that you cannot reset the counter to a value less than or equal to any that have already been used. For MyISAM, if the value is less than or equal to the maximum value currently in the AUTO_INCREMENT column, the value is reset to the current maximum plus one. For InnoDB, if the value is less than the current maximum value in the column, no error occurs and the current sequence value is not changed.

                如何使用另一个表中的 MAX 值重置 MySQL AutoIncrement? 关于如何动态获取可接受的值.

                See How can I reset an MySQL AutoIncrement using a MAX value from another table? on how to dynamically get an acceptable value.

                这篇关于如何在 MySQL 中重置 AUTO_INCREMENT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何以CSV格式输出MySQL查询结果? 下一篇:如何在MySql中返回具有相同列值的行

                相关文章

                最新文章

                <i id='cymRg'><tr id='cymRg'><dt id='cymRg'><q id='cymRg'><span id='cymRg'><b id='cymRg'><form id='cymRg'><ins id='cymRg'></ins><ul id='cymRg'></ul><sub id='cymRg'></sub></form><legend id='cymRg'></legend><bdo id='cymRg'><pre id='cymRg'><center id='cymRg'></center></pre></bdo></b><th id='cymRg'></th></span></q></dt></tr></i><div id='cymRg'><tfoot id='cymRg'></tfoot><dl id='cymRg'><fieldset id='cymRg'></fieldset></dl></div>
                  <legend id='cymRg'><style id='cymRg'><dir id='cymRg'><q id='cymRg'></q></dir></style></legend>

                  <tfoot id='cymRg'></tfoot>

                  <small id='cymRg'></small><noframes id='cymRg'>

                      <bdo id='cymRg'></bdo><ul id='cymRg'></ul>