MySQL实战篇:存过过程,procedure ,存储控制流程语句!

【存储过程理论】
1.sql语句无法编写处理流程的语句,存储过程就是数据库中保存的一些列sql命令的集合,可以通过存储过程就可以编写流程语句,如循环操作语句等。
2创建.语法
create procedure 存储过程名称(参数种类 参数 数据类型,...)
begin
处理内容
end
注:参数种类:in 输入 out 输出 inout 输入输出
3.使用语法
call 存储过程名称(参数,...)
【案例操作】
1.创建存储
-- create procedure p_fruits(inout f_price decimal(8,2) )
begin
if f_price is null or f_price='' then
select * from fruits;
else
select * from fruit where f_price=f_price;
end if;
end;
//


2.删除存储过程
drop procedure [if exists]存储过程名称;

3.查看存储过程的状态
show procedure status [like 'pattern' ]
