To check whether the event scheduler is currently enabled
Show variables like 'event _ schedount ';
Enable Event Viewer
Set global event_scheduler = 1;
Create event
Syntax:
Create event [if not exists] event_name
On schedule schedule
[On completion [NOT] PRESERVE]
[ENABLE | DISABLE]
[COMMENT 'comment']
DO SQL _statement;
Instance:
Create event updateInfoStatus
On schedule every 30 MINUTE
DO
UPDATE 'jd _ article' SET 'status' = 0 WHERE 'status' = 1 AND 'date' <= now ();
Modify event
Syntax:
Alter event event_name
[On schedule schedule]
[Rename to new_event_name]
[On completion [NOT] PRESERVE]
[COMMENT 'comment']
[ENABLE | DISABLE]
[DO SQL _statement]
Instance:
Alter event updateInfoStatus
On schedule every 30 MINUTE
DO
UPDATE 'jd _ article' SET 'status' = 0 WHERE 'status' = 1 AND 'date' <= now ();
Delete event
Drop events if exists updateInfoStatus
Temporarily close the event
Alter events updateInfoStatus DISABLE
Enable event
Alter events updateInfoStatus ENABLE
View event details
SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME = 'updateinfostatus' AND EVENT_SCHEMA = 'jdwc'
View All events
SHOW EVENTS
View event creation Information
Show create event updateInfoStatus
Author Zhou Hr