MySQL EVENT Scheduler
MySQL EVENT Scheduler is a SQL statement in the MySQL Specific category. MySQL: creates scheduled tasks that run at specified times (like cron for MySQL). Must be enabled. The syntax is CREATE EVENT event_name ON SCHEDULE EVERY 1 DAY STARTS '2026-01-01 00:00:00' DO sql_statement;. It returns scheduled event. A typical example: SET GLOBAL event_scheduler = ON; CREATE EVENT daily_cleanup ON SCHEDULE EVERY 1 DAY STARTS '2026-06-01 03:00:00' DO DELETE FROM logs WHERE created_at < DATE_SUB(NOW(), INTERVAL 90 DAY); -- View events: SHOW EVENTS; -- Drop event: DROP EVENT IF EXISTS daily_cleanup; A close relative is AUTO_INCREMENT, which mySQL auto-generates sequential integer values for this column. Commonly used with PRIMARY KEY. A close relative is ENGINE, which specifies the MySQL storage engine. InnoDB (default) supports transactions and foreign keys. MyISAM is faster for read-heavy. A close relative is LAST_INSERT_ID(), which returns the AUTO_INCREMENT value generated by the most recent INSERT in the current connection.