I. Overview
Stored procedure (Stored Procedure) is a large database system, in order to complete a specific set of functions set of SQL statements. Which is stored in a database, compiled after the first call does not need to compile again, the user name specified by the stored procedure parameters are given (if the stored procedure with parameters) to execute it.
A stored procedure is an important object in the database.
Second, the characteristics of the stored procedure
- To complete more complex computation and determination
- Programmable line of strong, flexible
- SQL programming code may be reused
- The relatively faster execution speed
- Reduce the data transmission between the network, to save money
Third, create a stored procedure test data
delimiter $$
create procedure add_enterprise_parameter(in loop_times int)
begin
declare i int default 0;
while i < loop_times do
set @name = CONCAT('张三',i);
set @contact =CONCAT('nana',i);
set @email = concat('huohu',i,'@test.com');
INSERT INTO demo(name,email,contact,country,state,address,province,create_time,modify_time)
VALUES(@name,@email,@contact,'China',Null,'浙江',sysdate(),'0000-00-00 00:00:00');
set i=i+1;
end while;
end
$$
delimiter ;
The use of methods
1, a direct call
call add_enterprise_parameter(100000);
Such data can be inserted into the data table;
2, navicat call
Right-click to display the run function, then the input parameters on it.