1

I am in the process of creating a Users table and would like each user to have a random User ID that will the the primary element and in an auto-increment/generated type of situation.

The format will be something like this: 246b6fe6-d1f2-4961-ae07-08f3057e0a13 and I would need each newly created user to be auto-assigned an internal "Person ID" under this format.

I don't think MySQL is able to handle this type of Unique ID (but I might be wrong).

Should I have a script generate a random string until one is found that isn't assigned then use it to create the entry in the table or is there an easier way that I'm just not yet aware of?

Thanks for your help!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
danny26b
  • 463
  • 2
  • 13
  • 4
    The format you've described is a standard GUID (with hyphens). Perhaps you could glean an answer from the combination of these related questions: [Best way to handle large (UUID) as a MySQL table primary key](https://stackoverflow.com/questions/16122934/best-way-to-handle-large-uuid-as-a-mysql-table-primary-key) or [guid as primary key?](https://stackoverflow.com/questions/4053036/guid-as-primary-key/4053222), [Generate GUID in MySQL for existing Data?](https://stackoverflow.com/questions/6280789/generate-guid-in-mysql-for-existing-data) – Tyler Roper Sep 29 '19 at 03:58
  • Incidentally, what does it matter what the format is of an internal key? – Strawberry Sep 29 '19 at 07:38

0 Answers0