Tuesday, March 26, 2013

Create Scheduler in Mysql


Repeactable Scheduler

CREATE EVENT daily_ranking
on SCHEDULE EVERY 1 DAY STARTS '2011-05-16 01:00:00' ENDS '2013-04-01 12:59:59'
DO
INSERT INTO SCHEDULER_TEST VALUES (NOW(), 'DONE');


every day on 01:00:00 doing insert in period

Only one time Scheduler 


CREATE EVENT daily_ranking
on SCHEDULE at CURRENT_TIMESTAMP + INTERVAL 1 HOUR
DO
INSERT INTO SCHEDULER_TEST VALUES (NOW(), 'DONE');




blow line is test and Query



CREATE EVENT daily_ranking
on SCHEDULE EVERY 1 DAY STARTS '2011-05-16 01:00:00' ENDS '2013-04-01 12:59:59'
DO
INSERT INTO SCHEDULER_TEST VALUES (NOW(), 'DONE');


CREATE EVENT daily_ranking_AT4
on SCHEDULE at CURRENT_TIMESTAMP + INTERVAL 1 MINUTE
DO
INSERT INTO SCHEDULER_TEST VALUES (NOW(), 'Test2');


SELECT * FROM INFORMATION_SCHEMA.EVENTS;

SELECT * FROM SCHEDULER_TEST;

SELECT NOW();

SELECT db, name, interval_value, interval_field, status, on_completion, time_zone, execute_at, starts, ends, last_executed, created, modified
from mysql.event;

SELECT event_schema, event_name, interval_value, interval_field, status, on_completion, time_zone, execute_at, starts, ends, last_executed, created, last_altered
from information_schema.events;


show global variables like '%sche%';

set global event_scheduler = 1 ;

No comments:

Post a Comment