MySQL timed task

Source: Internet
Author: User

Original: MySQL timed task

First, Introduction:

MySQL belongs to the small and medium database system, its event scheduler Events Scheduler is in MySQL 5.1 to start the introduction of the event Scheduler is another feature added in MySQL 5.1, can be used as a scheduled Task scheduler, Replaces some of the timing functions that were previously available only with the operating system Task Scheduler. The event Scheduler is timed to trigger execution, and can also be called a "temporary trigger" at this point in time. A trigger simply executes some statements for the events produced by a table, while the event scheduler executes some statements at a certain (interval) time. Events are managed by a particular thread, the so-called "event Scheduler". The version of MySQL that I use is MySQL 5.6.22.

Second, start the scheduled task:

1. By show variables like ' event_scheduler ' command, you can see if the event is on or SELECT @ @event_scheduler

If it is not turned on, it can be opened by command: Set global event_scheduler = 1;

2. Syntax:

CREATE EVENT [IF not EXISTS] Event_Name

On SCHEDULE SCHEDULE

On completion [NOT] PRESERVE]

[ENABLE | DISABLE] [COMMENT ' COMMENT '] do sql_statement/call PROCEDURE;

Schedule
at TIMESTAMP [+ INTERVAL INTERVAL]
| Every INTERVAL [starts TIMESTAMP] [ENDS TIMESTAMP]
  
INTERVAL:
Quantity {Year | QUARTER | MONTH | Day | HOUR | MINUTE |
WEEK | SECOND | Year_month | Day_hour | Day_minute |
Day_second | Hour_minute | Hour_second | Minute_second}

MySQL timed task

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.