mysql 定时任务

将事件计划开启: 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
delimiter //
CREATE PROCEDURE test ()
BEGIN
update examinfo SET endtime = now() WHERE id = 14;
END
//

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

//

你可能感兴趣的:(数据库)