Wednesday, August 11, 2010

MySQL - Event Scheduler - Example

event table exist in mysql database for more info. to get about event. It will be in MYsql VERSION > 5.1.16

CREATE TABLE a (
c1 INT(1));

SET GLOBAL event_scheduler = 1; -- Turn on event scheduler variable
-- DROP EVENT IF EXISTS insert_record;

DELIMITER //
CREATE EVENT IF NOT EXISTS insert_record
ON SCHEDULE AT now() + INTERVAL 1 MINUTE
[ON COMPLETION [NOT] PRESERVE]
DO
BEGIN
INSERT INTO a (c1) values (2);
INSERT INTO a (c1) values (5);
END//

select * from mysql.event;

No comments :

// Below script tag for SyntaxHighLighter