数据库添加sql语句,主键UUID()可以用@id引用代入

举例如下:

执行sql语句

set @id_one = UUID();
set @id_two = UUID();
set @id_three = UUID();


INSERT INTO iem_team(team_id,team_name,war_zone_id,war_zone_name,is_show) VALUES(@id_one,'测试一组','4312223e-ca5d-11ea-8c82-1c34da46c1f0','深圳战区',0);
INSERT INTO iem_team(team_id,team_name,war_zone_id,war_zone_name,is_show) VALUES(@id_two,'测试二组','4312223e-ca5d-11ea-8c82-1c34da46c1f0','深圳战区',0);
INSERT INTO iem_team(team_id,team_name,war_zone_id,war_zone_name,is_show) VALUES(@id_three,'测试三组','4312223e-ca5d-11ea-8c82-1c34da46c1f0','深圳战区',0);

INSERT INTO iem_user(expand_user_id,team_id,lead_name) VALUES(UUID(),@id_one,'张三11');
INSERT INTO iem_user(expand_user_id,team_id,lead_name) VALUES(UUID(),@id_two,'张三22');
INSERT INTO iem_user(expand_user_id,team_id,lead_name) VALUES(UUID(),@id_three,'张三33');

 

相当于把主键id用变量替换,然后应用于其它数据表需要该主键id的地方去。

上一篇:Chapter 6 链表(上):如何实现LRU缓存淘汰算法?


下一篇:realloc、malloc、free、calloc函数的用法。