Skip to content

Instantly share code, notes, and snippets.

@acosonic
Created December 24, 2022 23:49
Show Gist options
  • Save acosonic/d509e0df4705595c464e8dd62fbeb190 to your computer and use it in GitHub Desktop.
Save acosonic/d509e0df4705595c464e8dd62fbeb190 to your computer and use it in GitHub Desktop.
Truly random MySQL uuid (taken from https://stackoverflow.com/a/60091504/800965)
UPDATE mytable SET uuid=(LOWER(CONCAT(
LPAD(HEX(ROUND(rand()*POW(2,32))), 8, '0'), '-',
LPAD(HEX(ROUND(rand()*POW(2,16))), 4, '0'), '-',
LPAD(HEX(ROUND(rand()*POW(2,16))), 4, '0'), '-',
LPAD(HEX(ROUND(rand()*POW(2,16))), 4, '0'), '-',
LPAD(HEX(ROUND(rand()*POW(2,48))), 12, '0')
)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment