Home  >  Article  >  Database  >  Mysql auto_increment 重新计数(让id从1开始)_MySQL

Mysql auto_increment 重新计数(让id从1开始)_MySQL

WBOY
WBOYOriginal
2016-06-01 13:23:351004browse

bitsCN.com 方法一

delete from test;
alter table `test` auto_increment=1
(好处,可以设置AUTO_INCREMENT 为任意值开始)
提示:如果表列和数据很多,速度会很慢,如90多万条,会在10分钟以上。

方法二

truncate table test
(好处,简单,AUTO_INCREMENT 值重新开始计数)

一般情况下我们使用第二个就可以了,记住以上情况都是彻底删除所有记录。bitsCN.com

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn