MYSQL事件查看器使用介绍
程序员文章站
2024-02-13 14:59:52
要查看当前是否已开启事件调度器 show variables like 'event_scheduler'; 开启事件查看器 set global event_schedu...
要查看当前是否已开启事件调度器
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