mysql中如何把主键设置为uuid()

DELIMITER C R E A T E T R I G G E R ‘ i d t r i g g e r ‘ B E F O R E I N S E R T O N ‘ p r o d u c t ‘ F O R E A C H R O W B E G I N S E T n e w . i d = R E P L A C E ( U U I D ( ) , ′ − ′ , ′ ′ ) ; E N D CREATE TRIGGER `id_trigger` BEFORE INSERT ON `product` FOR EACH ROW BEGIN SET new.id=REPLACE(UUID(),'-',''); END CREATETRIGGERidtriggerBEFOREINSERTONproductFOREACHROWBEGINSETnew.id=REPLACE(UUID(),,);END
DELIMITER;
注意: id_trigger是触发器名称(名称随意),product是表名,id是主键

你可能感兴趣的:(mysql)