mysql基础四 存储过程

一、存储过程:变量的声明和赋值。

create procedure p1()

begin

declare age int default 18;

    set age :=age+20;

select age from dual;

end;

调用存储过程:call p1(); 其结果是如下:

二、存储过程:简单的控制语句。

create procedure p2()
begin

declare age int default 18;
if age>=18 then
 select ‘已成年‘ ;
else 
 select ‘未成年‘;
end if;

end;
调用存储过程:call p2(); 其结果是如下: