我想做这样的事:
create table app_users
(
app_user_id smallint(6) not null auto_increment primary key,
api_key char(36) not null default uuid()
);
但是,这会导致错误,是否有方法在MySQL中调用默认值的函数?
谢谢
发布于 2018-03-19 15:52:09
不你不能。
但是,可以很容易地创建一个触发器来执行此操作,例如:
CREATE TRIGGER before_insert_app_users
BEFORE INSERT ON app_users
FOR EACH ROW
SET new.api_key = uuid();
https://stackoverflow.com/questions/-100007672
复制相似问题