zoukankan      html  css  js  c++  java
  • mysql中创建event定时任务

    从网上借鉴大神的。

    1. use onlinexam;  
    2. -- 查看event事件是否开启  
    3. show variables like '%sche%';  
    4. -- 开启event事件  (非常重要)
    5. set global event_scheduler =1;  
    6. -- 创建存储过程  
    7. -- 更新试卷状态的存储过程  
    8. drop procedure if exists update_paperstatus;  
    9. create procedure update_paperstatus()  
    10. begin  
    11. update oe_paper  
    12. set oe_paper_status='1'  
    13. where oe_paper_startime<=now()  
    14. and oe_paper_endtime>=now()  
    15. and oe_paper_status!='2';  
    16. update oe_paper  
    17. set oe_paper_status='3'  
    18. where oe_paper_endtime<now();  
    19. end;  
    20. -- 查看库中有哪些存储过程  
    21. show procedure status where Db='mytest';  
    22. show procedure status where Db='onlinexam';  
    23. -- 创建定时任务  
    24. -- 每60s执行一次  
    25. DROP EVENT IF EXISTS e_updatePaperStatus; -- 删除事件  
    26. create event if not exists e_updatePaperStatus  
    27. on schedule every 10 second  -- 设置10秒执行一次  
    28. starts date_add(now(),interval 10 second) -- 在10后执行  
    29. on completion preserve   
    30. do call update_paperstatus();  
    31. -- 开启事件任务  
    32. alter event e_updatePaperStatus ON  
    33. COMPLETION PRESERVE ENABLE;  
    34. -- 关闭事件任务  
    35. alter event e_updatePaperStatus ON  
    36. COMPLETION PRESERVE DISABLE;  
  • 相关阅读:
    水晶报表参数字段在代码中赋值
    存储过程编写经验和优化措施
    积分与排名
    大话处理器
    抽象数学
    开普勒:天空的立法者
    Scalable Face Image Retrieval with IdentityBased Quantization and Multireference Reranking
    配色辞典
    图像识别顶级赛事
    Information Geometry
  • 原文地址:https://www.cnblogs.com/webttt/p/7838001.html
Copyright © 2011-2022 走看看