Note: The name of a stored procedure in mysql must be enclosed by brackets, even if there is no parameter transfer for the stored procedure. 1. Basic Syntax:
Create procedure sp_name () begin ...... end modify the command Terminator delimiter $
Example:
Create procedurecreate procedure myproce () beginINSERT INTO main (num) VALUES (15); end; call the stored procedure: call myproce (); view all the stored procedures in the database: show procedure status; view the stored procedure creation Code show create procedure proc_name; Delete the Stored procedure drop procedure proc_name
2. Basic Syntax:
Create function hello () RETURNS ...... RETURN
Example:
Create functionCREATE FUNCTION hello (s CHAR (20) returns char (50) return concat ('hello, ', s ,'! '); Call functionselect hello ('World'); view the code for creating the stored procedure function. show create function func_name; Delete drop function func_name;