douju1953 2014-06-05 15:43
浏览 8
已采纳

如果我在mysql中运行我的事件会发生什么?

I have created a small script in mysql and run it. It does create an event but what happens next? DO I still need to call it in php or does it run according to the schedule I declared within the even.

Here's my event

DELIMITER |

CREATE EVENT updatedoggytreat
ON SCHEDULE EVERY 1 MONTH STARTS '2011-07-01 00:00:00'
ON COMPLETION PRESERVE
DO
  BEGIN
    UPDATE animal SET treat = treat + 6, bone = 5 WHERE breed = 'Bulldog' ;
    UPDATE animal SET treat = treat + 3, bone = bone + 4 WHERE breed  = 'small dog';
    UPDATE animal SET treat = treat + 6, bone = 5 WHERE breed = 'mix breed';
    UPDATE animal SET treat = 10, bone = 5 WHERE breed  = 'doberman';
    UPDATE animal SET treat = 15 WHERE breed  = 'sheepdog';
  END |

 DELIMITER ;

Do I still have to call this one in php or does it runs automatically based on the schedule I stated.

Many Thanks.

  • 写回答

1条回答 默认 最新

  • dongshijiao2363 2014-06-05 15:46
    关注

    http://dev.mysql.com/doc/refman/5.1/en/events-overview.html

    You do not have to call it manually using anything. They are scheduled events or "temporal triggers".

    The SQL instance, that is, the server itself will manage it all. So long as your mysql is running, in accordance to the times that you set and periodicity etc, the event will trigger as you would expect.

    You might want to do some research into what happens if it happens to be down at the time the scheduled event is meant to occur - that may be a configuration option.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?