Posted By

jachin on 10/19/07


Tagged

sql auto increment AUTOINCREMENT


Versions (?)

Reset auto increment on a table


 / Published in: SQL
 

URL: http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html

If you are deleting all the rows in a table and you also want to reset the values that will get used by auto increment, this is how to do it.

  1. ALTER TABLE tbl AUTO_INCREMENT = 1;

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: Yeah on January 18, 2008

If you have already deleted all rows from table, you can truncate it. Effect will be the same. Also you can use truncate instead of using delete. Then you can do the same thing with one query.

You need to login to post a comment.