Original: MySQL timed task
First, Introduction:
MySQL belongs to the small and medium database system, its event scheduler Events Scheduler is in MySQL 5.1 to start the introduction of the event Scheduler is another feature added in MySQL 5.1, can be used as a scheduled Task scheduler, Replaces some of the timing functions that were previously available only with the operating system Task Scheduler. The event Scheduler is timed to trigger execution, and can also be called a "temporary trigger" at this point in time. A trigger simply executes some statements for the events produced by a table, while the event scheduler executes some statements at a certain (interval) time. Events are managed by a particular thread, the so-called "event Scheduler". The version of MySQL that I use is MySQL 5.6.22.
Second, start the scheduled task:
1. By show variables like ' event_scheduler ' command, you can see if the event is on or SELECT @ @event_scheduler
If it is not turned on, it can be opened by command: Set global event_scheduler = 1;
2. Syntax:
CREATE EVENT [IF not EXISTS] Event_Name
On SCHEDULE SCHEDULE
On completion [NOT] PRESERVE]
[ENABLE | DISABLE] [COMMENT ' COMMENT '] do sql_statement/call PROCEDURE;
Schedule
at TIMESTAMP [+ INTERVAL INTERVAL]
| Every INTERVAL [starts TIMESTAMP] [ENDS TIMESTAMP]
INTERVAL:
Quantity {Year | QUARTER | MONTH | Day | HOUR | MINUTE |
WEEK | SECOND | Year_month | Day_hour | Day_minute |
Day_second | Hour_minute | Hour_second | Minute_second}
MySQL timed task