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

  1. <tfoot id='XYIFM'></tfoot>
    <legend id='XYIFM'><style id='XYIFM'><dir id='XYIFM'><q id='XYIFM'></q></dir></style></legend>
    • <bdo id='XYIFM'></bdo><ul id='XYIFM'></ul>

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

    1. 如何重新编号主索引

      How to renumber primary index(如何重新编号主索引)
      • <tfoot id='VEryX'></tfoot>
      • <legend id='VEryX'><style id='VEryX'><dir id='VEryX'><q id='VEryX'></q></dir></style></legend>
          <tbody id='VEryX'></tbody>
        • <bdo id='VEryX'></bdo><ul id='VEryX'></ul>

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

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

              1. 本文介绍了如何重新编号主索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个简单的 MySQL 表,主索引 (id) 没有一一编号(1、31、35、100 等).我希望它们被编号为 (1, 2, 3, 4).请告诉我怎么做.我还想指出,我知道操作可能带来的后果,但我只是想整理一下桌子.

                I have got a simple MySQL table and primary index (id) is not numbered one by one (1, 31, 35, 100 etc.). I want them to be numbered like (1, 2, 3, 4). Please tell me how to do it. I would also like to point that I am aware of possible consequences of the operation, but I just want to tidy up the table.

                推荐答案

                我同意其他方法也可以,但我只是给出了不同的想法.这将不需要任何临时表创建要求::

                I agree other methods will work but I'm just giving a different idea. This will do without any temp table creation requirements::

                SET @i=0;
                UPDATE table_name SET column_name=(@i:=@i+1);
                

                这篇关于如何重新编号主索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Bogus foreign key constraint fail(虚假外键约束失败)
                how to get last insert id after insert query in codeigniter active record(如何在codeigniter活动记录中插入查询后获取最后一个插入ID)
                Force InnoDB to recheck foreign keys on a table/tables?(强制 InnoDB 重新检查表/表上的外键?)
                How to auto generate migrations with Sequelize CLI from Sequelize models?(如何使用 Sequelize CLI 从 Sequelize 模型自动生成迁移?)
                Clear MySQL query cache without restarting server(无需重启服务器即可清除 MySQL 查询缓存)
                ALTER TABLE to add a composite primary key(ALTER TABLE 添加复合主键)

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

                • <tfoot id='GjXiP'></tfoot>

                      <tbody id='GjXiP'></tbody>

                      1. <legend id='GjXiP'><style id='GjXiP'><dir id='GjXiP'><q id='GjXiP'></q></dir></style></legend>

                      2. <small id='GjXiP'></small><noframes id='GjXiP'>

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