1. Create a stored procedure
1 Create procedure Proc_name () 2 begin 3 SQL; 4 End
SQL executes the code at a fixed value, for example, inserting the current time into the table: INSERT INTO Table VALUES (now ()), and then execute the stored procedure periodically with event dispatch.
2. Create a Trigger Event
1 Create if not exists Event_Name 2 on - Second 3 on Completion Preserve 4 Do-Call Proc_name ()
Creates an event dispatch that executes the call to the stored procedure once every 30 seconds after the event dispatch completes. If you only want the stored procedure to execute only once at a time, change the preserve to not preserve.
3. Check if event is turned on
1 like ' %sche% '
4. Open the event plan
1 set global Event_scheduler=1;
Global event Dispatch switch, 1 is on, 0 is off.
5. Turn on event tasks
1 Alter on completion preserve enable;
Opens the specified event dispatch switch
6. Close Event Task
1 Alter on completion preserve disable;
Turn off the specified event dispatch switch
7. View all stored procedures in the database
1 SELECT * from MySQL. proc
View all stored procedures of the database, after MySQL installation, there is a database called MySQL by default, there is a table called Proc, by looking at this table can also query the database of all stored procedures.
8. View all stored procedures + content in the database
1 procedure Status;
9. View the creation code of a stored procedure or function
1 Create procedure You_proc_name;
10. Delete stored Procedures
1 Drop procedure Proc_name;
MySQL stored procedures and timed calls