189 8069 5689

怎么重置mysql自增,mysql自增序列重置

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

alter table table_name auto_increment=n;

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:域名注册、网络空间、营销软件、网站建设、永嘉网站维护、网站推广。

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

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

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

truncate table 表名

怎么重置mysql的自增列AUTO

重建列

truancate 表

使用命令,如下:

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

Your MySQL connection id is 2

Server version: 5.5.41-log MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

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

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

alter table t2 auto_increment=10;

Query OK, 2 rows affected (0.17 sec)

Records: 2 Duplicates: 0 Warnings: 0

mysql insert into t2 values();

Query OK, 1 row affected (0.05 sec)

mysql select * from t2;

+----+

| id |

+----+

| 1 |

| 2 |

| 10 |

+----+

3 rows in set (0.00 sec)

mysql

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

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

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


当前标题:怎么重置mysql自增,mysql自增序列重置
文章地址:http://cdxtjz.cn/article/heegge.html

其他资讯