mysql 定时器调用存储过程

#存储过程,更改7天外用户状态#
DELIMITER $$
CREATE PROCEDURE temp()
BEGIN
UPDATE zy_developer SET regstatus=1 WHERE TIMESTAMPDIFF(DAY,STR_TO_DATE(TIME,'%Y-%m-%D'),CURDATE()) >=7;
COMMIT;
END $$
DELIMITER;
#创建事件,1小时调用一次#
CREATE event IF NOT EXISTS temp_event ON SCHEDULE EVERY 1 HOUR 
ON COMPLETION PRESERVE 
DO CALL temp();
#查看定时器信息#
 SELECT * FROM information_schema.events;
 #开启事件#
 ALTER  event temp_event ON COMPLETION PRESERVE ENABLE;
 #删除事件#
 DROP event temp_event;

你可能感兴趣的:(存储过程,定时器,数据库)