1. How long is the distance from the current execution
DELIMITER $$
ALTER definer= ' admin ' @ '% ' EVENT ' epnrupdatestatusagain ' on SCHEDULE every 1 day starts ' 2015-07-24 14:45:00 ' on completion PRESERVE ENABLE do BEGIN
UPDATE diyfare. ' PNR '
SET diyfare. ' PNR '. ' Status ' =2
WHERE diyfare. ' PNR '. ' Status '! = 2
And now () between Date_sub (Diyfare "PNR". ' Deadline ', INTERVAL 1 day) and Diyfare. ' PNR '. ' Deadline ';
end$$
DELIMITER;
Date_sub ago
After Date_add
Gets the current time SELECT now ();
2. EVENT
--Check whether the timer is turned on
Show variables like '%sche% ';
--Turn on timer
Set global Event_scheduler = 1;
--changing separators
Mysql> delimiter//
--Create a stored procedure
Mysql> CREATE PROCEDURE pro_lqy_test_insert_23 ()
Begin
Insert into Lqy_test (title,content,createtime) VALUES (' title titles ', ' Con
Tent contents ', now ());
end//
Query OK, 0 rows Affected (0.00 sec)
--creation of events, executed 15:15:00 every day
Mysql> Create Event Event_lqy_test_insert_23
-On schedule
-Every 1 day starts ' 2012-04-24 15:15:00 '
Do-Call pro_lqy_test_insert_23 ()//
Query OK, 0 rows Affected (0.00 sec)
Mysql> delimiter;
--Start Event
Mysql> Alter event event_lqy_test_insert_23 on
-Completion preserve enable;
Query OK, 0 rows Affected (0.00 sec)
--Close Event
Mysql> Alter event event_lqy_test_insert_23 on
Completion preserve disable;
Query OK, 0 rows Affected (0.00 sec)
MySQL Event and time operation