MYSQL event viewer introduction _ MySQL

Source: Internet
Author: User
MYSQL Event Viewer use introduction bitsCN.com 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 HrbitsCN.com

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.