查看event是否开启: show variables like '%sche%';
将事件计划开启: set global event_scheduler=1;
关闭事件任务: alter event e_test ON COMPLETION PRESERVE DISABLE;
开户事件任务: alter event e_test ON COMPLETION PRESERVE ENABLE;

简单实例.
创建表 CREATE TABLE test(endtime DATETIME);

创建存储过程test
CREATE PROCEDURE test ()
BEGIN
update examinfo SET endtime = now() WHERE id = 14;
END;

创建event e_test
CREATE EVENT if not exists e_test
on schedule every 30 second
on completion preserve
do call test();

每隔30秒将执行存储过程test,将当前时间更新到examinfo表中id=14的记录的endtime字段中去.


使用navicat UI界面操作更方便,存储过程(函数)和计划任务(事件)


 mysql中查看Event作业情况

通过执行如下的语句:

SELECT * FROM information_schema.EVENTS

实用性语句

SELECT LAST_EXECUTED FROM information_schema.EVENTS WHERE EVENT_NAME='reset_score';

 

 

自动开启

在my.ini的[mysqld]下

event_scheduler=ON

通过执行如下的语句:

SELECT * FROM information_schema.EVENTS

实用性语句

SELECT LAST_EXECUTED FROM information_schema.EVENTS WHERE EVENT_NAME='reset_score';

 

 

自动开启

在my.ini的[mysqld]下

event_scheduler=ON

相关文章:

  • 2021-08-09
  • 2022-02-13
  • 2022-01-27
  • 2021-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-08
  • 2021-12-15
  • 2021-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
相关资源
相似解决方案