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