开发者

Is there any way to implement a time based trigger in Mysql 5.1?

开发者 https://www.devze.com 2022-12-16 06:45 出处:网络
Is there any way to implement a time based trigger in Mysql 5.1 i.e. it must run at 12H05 every day Edit

Is there any way to implement a time based trigger in Mysql 5.1

i.e. it must run at 12H05 every day

Edit

A corn job calling an SQL script is curren开发者_如何学Gotly been used - but I am looking for a less complicated solution.


To do this with Mysql 5.1.x use the following code:

CREATE EVENT myevent
    ON SCHEDULE
      EVERY 6 HOUR
    COMMENT 'A sample comment.'
    DO
      UPDATE myschema.mytable SET mycol = mycol + 1;

Here link to the users manual


Unless triggers in MySQL are different than in most other RDBMS, a time based trigger makes no sense. Triggers are fired in reaction to rows being added/inserted/deleted in a table. If you want a time based operation to occur, you should be considering a Job (in SQL Server) or Windows Service.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号