Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sandasan/03c25892cf4cd0892935d6736e618a1c to your computer and use it in GitHub Desktop.
Save sandasan/03c25892cf4cd0892935d6736e618a1c to your computer and use it in GitHub Desktop.
Reorder auto increment IDs on MySQL
SET @count = 0;
UPDATE table_name SET table_name.id = @count:= @count + 1;
ALTER TABLE table_name AUTO_INCREMENT = 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment