• notice
  • Congratulations on the launch of the Sought Tech site

Mysql event viewer use introduction

To check whether the event scheduler is currently enabled
SHOW VARIABLES LIKE'event_scheduler';

Open the 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;

Example:
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]

Example:
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

Temporarily turn off events
ALTER EVENTS updateInfoStatus DISABLE

Turn on events
ALTER EVENTS up dateInfoStatus 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

Tags

Technical otaku

Sought technology together

Related Topic

0 Comments

Leave a Reply

+