Drop and Recreate Auto_increment Index MYSQL

To prevent very large auto_increment indices sometimes it is good to reset the indices, so they can start again from 1, 2,3 4 …
You would want to do that if you are using one table and there are no relationships associated with the primary key of that table. An example of that could be when you import a large csv into MySQL, removing and importing the data over and over again.

First: drop the old one
ALTER TABLE test DROP COLUMN id;

Second: Recreate the index
ALTER TABLE test ADD COLUMN id INT UNSIGNED NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (ID);
Let's share thisShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn