MySQL timed task

Source: Internet
Author: User

Stored Procedure
Create
CREATE PROCEDURE Sp_name ()
Begin
.........
End

Call
Call Sp_name ()
Note: The stored procedure name must be appended with parentheses, even if the stored procedure has no parameters passed

Delete
drop procedure Sp_name

Other
1.show Procedure Status
Displays basic information about all stored procedures in the database, including the owning database, stored procedure name, creation time, etc.
2.show CREATE PROCEDURE Sp_name
Show details of a stored procedure

Example:
CREATE PROCEDURE ' Bag_app_flow ' ()
INSERT INTO Bag_app_flow
Select Pid,avg (in_speed), avg (out_speed), Max (Log_time) log_time
From Bag_app_flow_raw
Where hour (now ())-hour (log_time) = 1
Group BY Pid,date_format (Log_time, '%y-%m-%d%H ');

--------------
Event
Use any of the following sentences to open a scheduled task:
SET GLOBAL event_scheduler = on;
SET @ @global. Event_scheduler = on;
SET GLOBAL event_scheduler = 1;
SET @ @global. Event_scheduler = 1;
The basic syntax for Event Scheduler creation is:
CREATE EVENT
[IF not EXISTS]
Event_Name
On SCHEDULE SCHEDULE
[on completion [NOT] PRESERVE]
[ENABLE | DISABLE]
[COMMENT ' COMMENT ']
Do sql_statement
If you want to call procedure
Call Sp_name (), such as
Create Event Flow_job
On schedule every 1 hour
Starts ' 2009-12-26 18:06:00 '
Do
Call Bag_ip_flow ();
If you have more than one procedures, add begin...end, such as
Create Event Flow_job
On schedule every 1 hour
Starts ' 2009-12-26 18:06:00 '
Do
Begin
Call Bag_app_flow ();
Call Bag_ip_flow ();
Call Bag_ip_group_flow ();
End

MySQL timed task

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.