MySQL-事件EVENT-时间定时器

应用场景:一般用于在某一特定的时间点,触发相关的SQL语句或存储过程。

 

查看定时器开启状态:

SHOW VARIABLES LIKE 'event_scheduler';

开启定时器:0为OFF,1为ON

SET GLOBAL event_scheduler = 1;

关闭定时器:

SET GLOBAL event_scheduler = 0;

创建事件语法:

CREATE EVENT [IF NOT EXISTS] event_name

ON SCHEDULE schedule

[ON COMPLETION [NOT] PRESERVE]

[ENABLE | DISABLE | DISABLE ON SLAVE]

[COMMENT 'comment']

DO sql_statement;

注:

示例:

delimiter //
-- 定义一个事件,每隔一分钟,往member表中插入一条记录
CREATE EVENT IF NOT EXISTS event_insert_member
ON SCHEDULE EVERY 1 MINUTE
ON COMPLETION PRESERVE ENABLE DO
BEGIN
INSERT INTO member(mobilePhone,pwd) VALUES('18852145214','123');
END//
delimiter ;

 

 

 

上一篇:VASP赝势简介


下一篇:perspective 和 transform-style: preserve-3d;