Is there a way to create a table in MySql that it has an automatic ID field, but the ID is not sequential. For example, a random or pseudo random ID.
I have found solutions that suggest generating an ID and try to insert it until an unused ID is found (generating an sequential five digit alphanumerical ID).
but nothing that can be done directly in the table definition, or a simpler trick.
Is there a way to create a table in MySql that it has an
Share
MySQL has a native function
UUID()which will generate a globally unique identifier:You can store its output in a
CHAR(36)column.According to the documentation though,
Addendum Another option is
UUID_SHORT()for a 64-bitunsigned INTrather than a character field.