MySQL event Scheduler

Source: Internet
Author: User

The event scheduler is added to MySQL 5.1. Similar to the Job function of SQL Server.

1.Syntax:

EVENTView Code

The schedule statement can be expressed:

EVERY INTERVALView Code

The interval unit can be as follows:

Quarter hour minute second YEAR_MONTH DAY_HOUR DAY_MINUTE DAY_SECOND HOUR_MINUTE HOUR_SECOND MINUTE_SECONDView Code

2. Enable and disable the event Scheduler:

Before using this function, make sure that event_scheduler is enabled.

GLOBAL event_scheduler;View Code

3. Example:

Create a test database:

Tst_event (createtime );View Code

Create a test stored procedure:

Tst_event (View Code

Create an event Scheduler:

Event schedule every ends DATE_ADD (, INTERVALView Code

Modify the event Scheduler:

Schedule every ends DATE_ADD (, INTERVAL tst_event ();View Code

View the event Scheduler:

Information_schema.eventsView Code

4. scheduling at different intervals:

Run the scheduler one day later:

SCHEDULE AT INTERVALView Code

Run the scheduler on February 28:

SCHEDULEView Code

Daily Scheduler execution:

SCHEDULE EVERYView Code

Run the scheduler every day one day:

SCHEDULE EVERY INTERVALView Code

Run the scheduler every day and stop it after 10 days:

SCHEDULE EVERY INTERVALView Code

Start one day, run the scheduler every day, and stop after 10 days:

SCHEDULE EVERY INTERVALView Code

Run the scheduler once a day:

SCHEDULE EVERY COMPLETIONView Code

5. Delete the Scheduler:

EVENT event_nameView Code

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.