Mysql regular tasks
1. Check whether to open the event scheduler:
VARIABLES SHOW the LIKE ' event_scheduler ' ; # is not open you can not enable a timer (0 for: off, 1 on behalf of: ON)
# If you do not open the implementation of
SET GLOBAL event_scheduler = ON; # starts a timer
2. Create EVENT event syntax:
# EXAMPLE executed once every 10 seconds, the CREATE the EVENT timer event name name #event the ON the SCHEDULE EVERY 10 SECODE # scheduled time every 10 seconds (event can set the [ Example: MONTH, DAY, SECODE, ...... ] ) the ON COMPLETION the PRESERVE # when this event expired, event will be disable, the event will still exist but the ENABLE # open event scheduling the DO the cALL stored procedure name (); # operation timing of the scheduling to be performed (the above-described scheduling task call create a stored procedure execution cycle of the task) . Example # 12 o'clock monthly January 1 implementation of
the cREATE EVENT timer name ON SCHEDULE EVERY 1 mONTH STARTS DATE_ADD (DATE_ADD (DATE_SUB (CURDATE (), INTERVAL DAY (CURDATE ()) - 1 DAY ), INTERVAL 1 MONTH), The INTERVAL 12 is HOUR) # set the start time, interval time to execute the ON COMPLETION the PRESERVE the ENABLE the DO the CALL stored procedure name ();
Note: Stored procedures can reference one on my https://www.cnblogs.com/Moming0/p/11428960.html
3. On / Off timed event
# Enable timed event the ALTER EVENT timer event name ON COMPLETION PRESERVE ENABLE; # closing timing of the event the ALTER EVENT timer event name ON COMPLETION PRESERVE DISABLE;
4. Delete timed events
DROP EVENT timed event name;
Note: Navicat tool created directly refer to this article https://blog.csdn.net/tantexian/article/details/50317829