![why](/static/img/x1mno0Ukhc-600.jpeg)
Don’t you love that every major database on the planet thinks that we (as in developers) don’t need to have a common syntax and that we should spend hours looking for the needed functionality?
Well, it just so happens that I was in need for generating a unique ID today with the database function – also know as UUID. A UUID is a string that is unique and looks something like “0302B2FE-8046-45D1-AB584481D0F2A99E”.
So, without further due here are the different functions for:
MySQL
[code]SELECT uuid() FROM …[/code]
MS SQL
[code]SELECT newid() FROM …[/code]
DB2
[code]SELECT generate_unique() FROM …[/code]
Oracle
[code]SELECT sys_guid() FROM …[/code]
H2
[code]SELECT random_uuid() FROM …[/code]
Yep, that’s right. Each function is named completely different, so it was not so easy to find them as quickly as I thought. In any case, hope this helps.