首页 > 解决方案 > MySQL uuid 未创建表

问题描述

尝试创建此表:

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

但它不工作

错误是:

[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版本是:8.0.4

欢迎任何其他关于如何在 MySQL 中生成 uuid v4 的建议

我试过的:

编辑:

建议来自这里:How to generate/autoincrement guid on insert without triggers and manual inserts in mysql?

标签: mysql

解决方案


推荐阅读