Home >Database >Mysql Tutorial >MYSQL 事件高度器_MySQL

MYSQL 事件高度器_MySQL

WBOY
WBOYOriginal
2016-06-01 13:48:35967browse

bitsCN.com

要查看当前是否已开启事件调度器
SHOW VARIABLES LIKE 'event_scheduler';

开启事件高度器
SET GLOBAL event_scheduler = 1;

创建事件
语法:
CREATE EVENT [IF NOT EXISTS] event_name
ON SCHEDULE schedule
[ON COMPLETION [NOT] PRESERVE]
[ENABLE | DISABLE]
[COMMENT 'comment']
DO sql_statement;

实例:
CREATE EVENT updateInfoStatus  
ON SCHEDULE EVERY 30 MINUTE   
DO
UPDATE `jd_article` SET `status` = 0 WHERE `status` = 1 AND `date`
修改事件
语法:
ALTER EVENT event_name
[ON SCHEDULE schedule]
[RENAME TO new_event_name]
[ON COMPLETION [NOT] PRESERVE]
[COMMENT 'comment']
[ENABLE | DISABLE]
[DO sql_statement]

实例:
ALTER EVENT updateInfoStatus  
ON SCHEDULE EVERY 30 MINUTE   
DO
UPDATE `jd_article` SET `status` = 0 WHERE `status` = 1 AND `date`
删除事件
DROP EVENTS IF EXISTS updateInfoStatus

临时关闭事件
ALTER EVENTS updateInfoStatus DISABLE

开启事件
ALTER EVENTS updateInfoStatus ENABLE

查看事件详细信息
SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME = 'updateInfoStatus' AND EVENT_SCHEMA = 'jdwc'

查看所有事件
SHOW EVENTS

查看事件创建信息
SHOW CREATE EVENT updateInfoStatus

bitsCN.com
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:什么是MongoDB_MySQLNext article:什么是NoSQL_MySQL