Home > Database > Mysql Tutorial > Mysql auto_increment 重新计数_MySQL

Mysql auto_increment 重新计数_MySQL

WBOY
Release: 2016-06-01 13:44:46
Original
861 people have browsed it

bitsCN.com

 

当清空一个表的时候,重新插入数据,发现auto_increment属性的字段计数不是从1开始的时候,可以使用以下命令

方法一

 

delete from test;

alter table `test` auto_increment=1

(好处,可以设置AUTO_INCREMENT 为任意值开始)

提示:如果表列和数据很多,速度会很慢,如90多万条,会在10分钟以上。

方法二

truncate table test

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

 

摘自 ay暗影

bitsCN.com
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template