Skip to content

Instantly share code, notes, and snippets.

@tan-i-ham
Forked from irazasyed/reset_id_column.sql
Created October 4, 2018 07:08
Show Gist options
  • Save tan-i-ham/cd7349bbf767de48844c53f2326158ba to your computer and use it in GitHub Desktop.
Save tan-i-ham/cd7349bbf767de48844c53f2326158ba to your computer and use it in GitHub Desktop.
MySQL: Reset id column to auto increment from 1
-- your_table: The table to modify
-- id: The id field/column to reset
SET @num := 0;
UPDATE your_table SET id = @num := (@num+1);
ALTER TABLE your_table AUTO_INCREMENT =1;
@tan-i-ham
Copy link
Author

reset mysql table id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment