MySQL-Event 使用案列

查看事件
1
show events
创建事件
1
2
3
4
5
CREATE  EVENT if not exists `reset_account_crawled_today_post`
ON SCHEDULE EVERY 1 DAY
STARTS '2016-09-29 00:00:00'
DO
update sogou_weixin_account_latest_article_crawl_task set crawled_today_post=0
更新事件
1
2
3
4
5
6
ALTER EVENT reset_today_execute_count
ON SCHEDULE EVERY 1 DAY
COMMENT '每天定时重置 今天任务执行次数 字段'
DO
UPDATE `sogou_weixin_account_latest_article_crawl_task` SET today_execute_count = 0;
UPDATE `sogou_weixin_article_grow_trend_task` SET today_execute_count = 0;
删除事件
1
DROP EVENT IF EXISTS reset_today_execute_count
查看创建事件
1
SHOW CREATE EVENT reset_account_crawled_today_post