SHOW VARIABLES like ' Event_scheduler '; ==> query Whether the event is turned on
SET GLOBAL Event_scheduler = 1;==> Opens the event
set Event_scheduler is always on
in MY.CNF or My.ini, add event_scheduler=1 or mysqld.--event_scheduler=1
DROP event if exists event_name;==> But when an event is running, deleting the event does not cause the event to stop, and the event executes until it finishes.
When using the event, note that the timer is turned on on the main library, the timer is turned off from the library, the event trigger all actions are recorded binlog for master-slave synchronization, and the timer opening from the library is likely to cause the card library. After switching the main library, remember to turn on the timer on the new Main library.
CREATE EVENT [Ifnot EXISTS] Event_Name
On SCHEDULE SCHEDULE//at TIMESTAMP [+ INTERVAL INTERVAL] | Every INTERVAL [starts TIMESTAMP] [ENDS TIMESTAMP] INTERVAL 5
DAY 5天后
On completion [NOT] PRESERVE]
[ENABLE | DISABLE]
[COMMENT ' COMMENT ']
Do sql_statement;
< Span style= "Color:rgb (51,51,51); Font-family:arial;font-size:14px;line-height:26px;background-color:rgb ( 255,255,255); " >
< Span style= "Color:rgb (51,51,51); Font-family:arial;font-size:14px;line-height:26px;background-color:rgb ( 255,255,255); " >//per minute
DELIMITER//
CREATE Event Inserttable
On SCHEDULE every 1 MINUTE
Do INSERT into Test VALUES (Current_timestamp)
//
DELIMITER;
Specify the time of day
DELIMITER//
CREATE Event Inserttable
On SCHEDULE every 1 day starts ' 2012-09-26 14:55:00 '
Do INSERT into Test VALUES (Current_timestamp)
//
DELIMITER;
ALTER EVENT inserttable disable;==> temporarily stopped
SHOW processlist; ==> View ID
SHOW EVENTS; ==> View information
SELECT * from Mysql.event; ==> View more information
Alter event inserttable on SCHEDULE every 1 day starts ' 2012-09-26 15:19:00 ';==> modified
Actual case:
the number of each month 1 o'clock in the morning executes:
CREATE EVENT not EXISTS STAT
On SCHEDULE every 1 MONTH starts Date_add (Date_add (Date_sub (), Curdate Day (INTERVAL ()) – 1 day), Curdate 1 MONTH), INTERVAL 1 HOUR)
On completion PRESERVE ENABLE
Do
BEGIN
Multiple statements
END
This article is from the "Blue Sky" blog, make sure to keep this source http://shurk.blog.51cto.com/1134443/1746306
Mariadb/mysql Event Usage Daquan