MySQL generated UID

André Figueira picture André Figueira · Mar 20, 2012 · Viewed 15.2k times · Source

I am coding a messaging system and I don't want to have short IDs shown, is there any way that MySQL can generate a UID which is unique as UID suggests?

I need to know how I can do this with ONLY MySQL, no PHP, JavaScript or anything else, just MySQL, if not possible, fine, I just want to make sure.

Sorry, I should have made it more clear when I say UID I just mean "Unique ID" but I need it in a multidigit number only, e.g. 914888629, 3890692140

Answer

juergen d picture juergen d · Mar 20, 2012

MySQL has a function for that. Try:

SELECT UUID();