mysql - 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 的建议
我试过的:
- 升级到 MySql 8.0.11
- 去掉括号:
uuid_to_bin(uuid())
编辑:
建议来自这里:How to generate/autoincrement guid on insert without triggers and manual inserts in mysql?
解决方案
推荐阅读
- image - Flutter中如何在网络镜像中设置超时参数?
- delphi - WebView2 (TEdgeBrowser) 在后台不工作(如果在屏幕上不可见) - 仅显示为灰色矩形
- c++ - 有人可以告诉我为什么我在 30 Day of Code Challenge 的 GeeksforGeeks 代码编辑器上遇到这个问题吗?
- kubernetes - Kubernetes:将每个 Pod 暴露在唯一的端口下
- javascript - 来自浏览器控制台的 Google Recaptcha v3
- php - 尝试在mac上设置php环境,文件不存在
- sql - 合并语法,使用子查询时的括号
- javascript - PostgreSQL 未连接
- r - RStudio 不断将 `/usr/local/bin` 添加到 PATH 变量的前面
- javascript - 如何使用 MongoDB 查询获取每个月的注册用户数?