Events Overview
An introduction to creating and managing scheduled events, which are named database objects containing SQL statements to be executed by the Event Scheduler.
Events are named database objects containing SQL statements that are to be executed at a later stage, either once off, or at regular intervals.
They function very similarly to the Windows Task Scheduler or Unix cron jobs.
Creating, modifying or deleting events requires the EVENT privilege.
Creating Events
Events are created with the statement.
Executing Events
Events are only executed if the event scheduler is running. This is determined by the value of the system variable, which needs to be set to On for the event scheduler to be running.
You can check if the Event scheduler is running with:
If the event scheduler is not running and event_scheduler has been set to OFF, use:
to activate it. If event_scheduler has been set to Disabled, you cannot change the value at runtime. Changing the value of the event_scheduler variable requires the SUPER privilege.
Since , setting the system variable will also try to reload the if it was not properly loaded at startup.
Viewing Current Events
A list of current events can be obtained with the statement. This only shows the event name and interval - the full event details, including the SQL, can be seen by querying the , or with .
If an event is currently being executed, it can be seen by querying the , or with the statement.
Altering Events
An event can be changed with the statement.
Dropping Events
Events are dropped with the statement. Events are also automatically dropped once they have run for the final time according to their schedule, unless the ON COMPLETION PRESERVE clause has been specified.
This page is licensed: CC BY-SA / Gnu FDL