Skip to content

Instantly share code, notes, and snippets.

@carloscarcamo
Last active August 10, 2022 08:22
Show Gist options
  • Save carloscarcamo/28441ee9b3a9c7807ce4 to your computer and use it in GitHub Desktop.
Save carloscarcamo/28441ee9b3a9c7807ce4 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;
@kazekaoru
Copy link

thanks

@diivi
Copy link

diivi commented Aug 25, 2020

thx!

@cvs07
Copy link

cvs07 commented Nov 24, 2021

Thanks

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