mysql存储过程批量提交_mysql执行存储过程批量插入随机数据

创建存储过程,执行

drop procedure if exists u_head_and_low_pro;

delimiter //

create procedure u_head_and_low_pro()

begin

DECLARE n int DEFAULT 0;

WHILE n < 1000 DO

insert into activity(data_code, coupon_activity_number, coupon_activity_title, coupon_activity_category,

coupon_activity_type, product_type, coupon_type, currency_type, full_amount,

decrease_amount, total_amount, take_amount, untake_amount, used_amount, per_user_limit,

effective_caculate_mode, begin_effective_time, end_effective_time,

coupon_activity_status, remark, create_by, create_time, update_by, update_time,

del_flag, lock_version)

values (CONCAT('248681711918', LPAD((@i:=n + 1), 4, 0)), left (upper (replace(uuid(), '-', '')), 5),

"活动", 2, 2, 2, 1, "HKD", 1000, 100, 1, 0, 1, 0, 1, 1, "2017-02-01 00:00:00",

"2018-02-25 23:59:59", 1, "后台批量添加1000条数据", "system", now(), "system", now(), 0, 0);

set n = n + 1;

END WHILE;

commit;

end;;

call u_head_and_low_pro();

将查询结果批量插入另一张表

insert into rule(data_code,coupon_activity_code,trip_type, begin_departure_time,end_departure_time,departure_days,remark,create_by,create_time,update_by,update_time,

del_flag,lock_version)

select

CONCAT('258681711911', LPAD((@i:=@i + 1), 4, 0)) AS data_code,

couponActivity.data_code,

'["1","2"]',"2017-12-01 00:00:00","2018-09-01 23:59:59",'["1","2","3","4","5","6","7"]',

"后台批量添加1000条数据","system",now(),"system",now(),0,0

from activity as couponActivity,(select @i:=0) as it

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值