mysql中每隔一段时间自动执行一次sql语句是怎么回事?
1个回答
展开全部
show variables like '%sche%';
set global event_scheduler =1;
update_a
mysql> create procedure update_a() update a set a.y_avg=(select avg(b.youhao) from b where a.a_id=b.a_id);
event e_updateA
mysql> create event if not exists e_updateA
-> on schedule every 60 second
-> on schedule at date_add(now(),interval 1 minute)
-> on completion preserve
-> do call update_a();
mysql> alter event e_updateA ON
-> COMPLETION PRESERVE DISABLE
mysql> alter event e_updateA ON
-> COMPLETION PRESERVE ENABLE;
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询