MySQL 关于存储过程的操作
-- 存储过程 --> 一组为了完成特定功能的SQL语句集 -- IN 传入参数 delimiter // create procedure mysql ( IN id int ) begin select * from table_name where id = id; end; // delimiter; --其中in是传进去的变量; drop procedure mysql;//销毁这个存储过程 --调用存储过程 call mysql(1); -- OUT 输出参数 delimiter // create procedure demo (in id1 int,OUT ids int) begin select id into ids from users where id = id1; select ids; end // delimiter ; --调用 set @result; call demo(1,@result); --INOUT输入输出 delimiter // create procedure demo (inout ids int) begin select id into ids from users where id =ids; select ids; end // delimiter ; --调用 set @result1 =2; call demo(@result1);
示例:
delimiter // create procedure insertData() begin declare i int default 1; while i <= 6388 do insert into healerjean1(name,email,message) values(i,(i+1),(i+2)); set i = i + 1; end while; end // delimiter ;