How to generate a new Guid in stored procedure?

前端 未结 5 802
时光说笑
时光说笑 2021-02-03 16:16

I currently have a stored procedure in which I want to insert new rows into a table.

insert into cars
(id, Make, Model)
v         


        
5条回答
  •  心在旅途
    2021-02-03 17:14

    In MySQL it is UUID(). so the query would be:

    insert into cars
    (id, Make, Model)
    values(UUID(), "Ford", "Mustang")
    

    if you want to reuse the uuid you can do it like this:

    set @id=UUID();
    insert into cars
    (id, Make, Model)
    values(@id, "Ford", "Mustang");
    select @id;
    

提交回复
热议问题