Skip to content

Instantly share code, notes, and snippets.

@Hazem-Ben-Khalfallah
Last active November 7, 2019 08:50
Show Gist options
  • Save Hazem-Ben-Khalfallah/17017e4abb99d5e6dda215fd9e03725b to your computer and use it in GitHub Desktop.
Save Hazem-Ben-Khalfallah/17017e4abb99d5e6dda215fd9e03725b to your computer and use it in GitHub Desktop.
[UUID to string in Mysql] #sql #mysql
#MySQL 8
#convert uuid binary(16) to String
SELECT BIN_TO_UUID(uuid) FROM foo
#convert uuid string to binary(16)
SELECT UUID_TO_BIN(UUID())
#MySQL 5,6,7
#convert uuid binary(16) to String
SELECT HEX(uuid) FROM foo
#convert uuid string to binary(16)
SELECT UNHEX(replace(UUID(), '-', ''))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment