MySQL Event Viewer Usage Introduction

Source: Internet
Author: User

to see if the event Scheduler is currently turned on
SHOW VARIABLES like ' Event_scheduler ';

Turn on 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 MINUTE
Do
UPDATE ' jd_article ' SET ' status ' = 0 WHERE ' status ' = 1 and ' Date ' <= now ();

Modifying Events
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 MINUTE
Do
UPDATE ' jd_article ' SET ' status ' = 0 WHERE ' status ' = 1 and ' Date ' <= now ();

Delete Event
DROP EVENTS IF EXISTS updateinfostatus

Temporary shutdown Events
ALTER EVENTS updateinfostatus DISABLE

Turn on Events
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

viewing event creation Information
SHOW CREATE EVENT updateinfostatus

MySQL Event Viewer Usage Introduction

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.