MYSQL Events

MYSQL Events

A mySQL event is the mySQL version of a Linux cron job. An event can be used to run a mysql query at a specified interval.The code below shows how to create an event called 'update_log' that will insert a row into the log table every 2 minutes.

mysql> CREATE EVENT update_log
-> ON SCHEDULE EVERY 2 MINUTE
-> DO INSERT INTO log VALUES(NULL, now());
mysql> CREATE EVENT update_log
-> ON SCHEDULE EVERY 2 MINUTE
-> DO INSERT INTO log (id, time) VALUES(NULL, now());