The event scheduler is added to MySQL 5.1. Similar to the Job function of SQL Server.
1.Syntax:
EVENTView Code
The schedule statement can be expressed:
EVERY INTERVALView Code
The interval unit can be as follows:
Quarter hour minute second YEAR_MONTH DAY_HOUR DAY_MINUTE DAY_SECOND HOUR_MINUTE HOUR_SECOND MINUTE_SECONDView Code
2. Enable and disable the event Scheduler:
Before using this function, make sure that event_scheduler is enabled.
GLOBAL event_scheduler;View Code
3. Example:
Create a test database:
Tst_event (createtime );View Code
Create a test stored procedure:
Tst_event (View Code
Create an event Scheduler:
Event schedule every ends DATE_ADD (, INTERVALView Code
Modify the event Scheduler:
Schedule every ends DATE_ADD (, INTERVAL tst_event ();View Code
View the event Scheduler:
Information_schema.eventsView Code
4. scheduling at different intervals:
Run the scheduler one day later:
SCHEDULE AT INTERVALView Code
Run the scheduler on February 28:
SCHEDULEView Code
Daily Scheduler execution:
SCHEDULE EVERYView Code
Run the scheduler every day one day:
SCHEDULE EVERY INTERVALView Code
Run the scheduler every day and stop it after 10 days:
SCHEDULE EVERY INTERVALView Code
Start one day, run the scheduler every day, and stop after 10 days:
SCHEDULE EVERY INTERVALView Code
Run the scheduler once a day:
SCHEDULE EVERY COMPLETIONView Code
5. Delete the Scheduler:
EVENT event_nameView Code