How does mysql reset the self-incrementing ID

Method 1, execute SQL:
truncate table test; (assuming your table name is test here)
The advantage of this method is that it runs super fast
 
Method 2, execute the following SQL: (Assume the table name is test)
delete from test;
alter table ` test` auto_increment=1;
the advantage of this method is that it can start from any value, the disadvantage is that if the amount of data is large, delete from test; is very time-consuming

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325830135&siteId=291194637