网站首页 > 文章中心 > 其它

怎么重置mysql自增

作者:小编 更新时间:2023-09-04 15:53:20 浏览量:63人看过

如何才能让mysql自动递增的字段重新从1开始

alter table table_name auto_increment=n;

注意n只能大于已有的auto_increment的整数值,小于的值无效.

show table status like 'table_name' 可以看到auto_increment这一列是表现有的值.

怎么重置mysql自增-图1

如果曾经的数据都不需要的话,可以直接清空所有数据,并将自增字段恢复从1开始计数

truncate table 表名

怎么重置mysql的自增列AUTO

重建列

truancate 表

使用命令,如下:

Welcome to the MySQL monitor. Commands end with ; or \g.

Oracle is a registered trademark of Oracle Corporation and/or its

怎么重置mysql自增-图2

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql use test

Database changed

+----+

| id |

| 1 |

| 10 |

mysql

修改mysql中自增序列的值,恢复初始值

两种方法修改或者重置mysql中的自增字段的值:autoIncrement;

其中方法二可以修改成任意值.

以上就是土嘎嘎小编为大家整理的怎么重置mysql自增相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章