A stored procedure (Stored Procedure) is a set of SQL statements that are compiled to perform a particular function, stored in a database, and invoked by the user by specifying the name of the stored procedure and given the parameter (if the stored procedure has parameters).
A stored procedure is a programmable function that is created and saved in the database. It can consist of SQL statements and some special control structures. Stored procedures are useful when you want to perform the same functions on different applications or platforms, or encapsulate specific functionality. Stored procedures in a database can be seen as simulations of object-oriented methods in programming. It allows control over how data is accessed.
1.MySQL creating a Stored procedure:
DELIMITER//
CREATE PROCEDURE procedure_name ([process parameters [,...]])
BEGIN
Process Body
END
//
DELIMITER ;
1 DELIMITER // 2 create procedure pro_01 (out C Span style= "color: #0000ff;" >int ) 3 begin 4 select @c : (* ) from User_tab; 5 6 // 7 DELIMITER;
CREATE PROCEDURE
1 #执行过程 2 Call pro_01 (@c);
#执行过程
1 SELECT @c;
SELECT @c;
MySQL stored procedures