MySQL创建存储过程
1.查询某个数据库的中存在的存储过程
use mvc_study;#选择数据库 show procedure status where Db='mvc_study';#查询数据库中存在的存储过程
2.创建一个无参数的数据库存储过程并执行
create procedure hi() select 'hello';#创建一个简单的存储过程 call hi();#执行这个存储过程
3.创建有参数的存储过程并执行
create procedure test02(a int,b int)#创建带参数的存储过程
begin
declare c int;
if a is null then
set a=0;
end if ;
if b is null then
set b=0;
end if ;
set c =a +b;
select c as sum;
end;
call test02(10,20);#执行带参数的存储过程
set @aa=150;
set @bb=120;
call test02(@aa,@bb);#执行带参数的存储过程
3.删除存储过程
drop procedure procedurename;#删除存储过程

浙公网安备 33010602011771号