1

trying to create this table:

CREATE TABLE IF NOT EXISTS my_table
(
    id          BINARY(16) default (uuid_to_bin(uuid()))
);

But it is not working

the error is:

[42000][1064] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(uuid_to_bin(uuid())) )' at line 2

MySQL version is: 8.0.4

Any other suggestions on how to generate an uuid v4 in MySQL are welcome

What I have tried:

  • Upgrade to MySql 8.0.11
  • Remove the parenthesis: uuid_to_bin(uuid())

EDIT:

The suggestion comes from here: How to generate/autoincrement guid on insert without triggers and manual inserts in mysql?

Matteo
  • 2,256
  • 26
  • 42

0 Answers0