MYSQL事件查看器使用介绍
编程学习 2021-07-05 15:27www.dzhlxh.cn编程入门
MYSQL事件查看器使用介绍,需要的朋友可以参考下
要查看当前是否已开启事件调度器
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` <= now( );
修改事件
语法:
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` <= now( );
删除事件
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
作者 Zhou Hr
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` <= now( );
修改事件
语法:
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` <= now( );
删除事件
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
作者 Zhou Hr
上一篇:mysql命令行下用户管理方法分享
下一篇:mysql中为用户设置密码的多种方法