新聞中心
如何才能讓mysql自動遞增的字段重新從1開始
alter table table_name auto_increment=n;
讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對這個(gè)行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長期合作伙伴,公司提供的服務(wù)項(xiàng)目有:域名注冊、網(wǎng)絡(luò)空間、營銷軟件、網(wǎng)站建設(shè)、永嘉網(wǎng)站維護(hù)、網(wǎng)站推廣。
注意n只能大于已有的auto_increment的整數(shù)值,小于的值無效.
show table status like 'table_name' 可以看到auto_increment這一列是表現(xiàn)有的值.
如果曾經(jīng)的數(shù)據(jù)都不需要的話,可以直接清空所有數(shù)據(jù),并將自增字段恢復(fù)從1開始計(jì)數(shù)
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中自增序列的值,恢復(fù)初始值
兩種方法修改或者重置mysql中的自增字段的值:autoIncrement;
其中方法二可以修改成任意值。
分享標(biāo)題:怎么重置mysql自增,mysql自增序列重置
分享URL:http://www.ef60e0e.cn/article/heegge.html