要檢視當前是否已開啟事件排程器
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 event if exists updateinfostatus
臨時關閉事件
alter event updateinfostatus disable
開啟事件
alter event updateinfostatus enable
檢視事件詳細資訊
select * from information_schema.events where event_name = 'updateinfostatus' and event_schema = 'jdwc'
檢視所有事件
show events
檢視事件建立資訊
show create event updateinfostatus
mysql 事件排程器 MySQL事件排程器
一 建立排程器 將資料庫按自定義的時間週期觸發某種操作,類似linux下的crontab 例項 建立排程器後的每個1小時觸發一次 create event myevent on schedule at current timestamp interval 1 hour doupdate mysche...
MySQL事件排程器
事件排程器 event scheduler 可以定時執行某些特定任務,可以看做基於時間的觸發器.show variables like event scheduler select event scheduler set global event scheduler 1 show create ev...
MySQL事件排程器 CREATE EVENT
mysql事件排程器 create event mysql從5.1開始支援event功能,有點類似於mssql的job,可以定時自動執行資料彙總。語法 create event if notexists event name onschedule schedule oncompletion not ...