Similar to my previous post, this code generates a UUID of the new v7 type, which has a Unix-timestamp base. This keeps UUIDs sortable by creation-date, which is useful when using them as database keys, for example You can either use this inline in your select statement, or convert it to a function.
Tag Archives: mysql
UUIDv4 in MySQL
Although MySQL has a UUID() function, it returns a version 1 UUID, which is time-based and has mostly been replaced by the completely random version 4. I recently needed a v4 in a query, and adapted this from some different options I found online: You can either use this inline in your select statement, or convert […]