3

How can I configure my table in MySQL Workbench to auto generate a UUID on INSERT?

I have set the column as VARCHAR(128), PK, NN, G with the default expression as UUID(). When I create a record the ID is 'UUID()'.

How can I get the database to generate UUID's automagically on INSERT? All the examples I see are auto-increment but UUID's are character strings so I can't use auto-increment.

MoreScratch
  • 2,933
  • 6
  • 34
  • 65
  • Possible duplicate of [MySQL - autoincrement to guid](https://stackoverflow.com/questions/5230638/mysql-autoincrement-to-guid) – PressingOnAlways Jul 18 '17 at 00:06
  • Please check https://stackoverflow.com/questions/5793203/how-can-affect-performance-when-i-use-uuids-as-my-primary-keys-in-mysql if you really want to use UUID as the primary key for your table. – Progman Oct 24 '17 at 20:06

1 Answers1

3

If you are using a non-standard DB, like MariaDB, you have to leave the G unchecked, use uuid() in Default/Expression column and you should be good to go.

Kalle Richter
  • 8,008
  • 26
  • 77
  • 177
kurt
  • 338
  • 3
  • 8