简而言之,类似于封装函数
特点
基本语法

create peocedure p1()
begin
select coun(*) from studuent;
end;
call p1();
设置完别忘了把delimiter改回来
变量
系统变量


用户自定义变量
set @myname = 'its';
set @myage := 10;

局部变量

if

参数(IN,OUT,INOUT)

case

create procedure p1(in month int)
begin
declare result varchar(10);
case
when month>=1 and month <=3 then
set result := '一';
when month>=4 and month <=6 then
set result := '二';
when month>=7 and month <=9 then
set result := '三';
when month>=10 and month <=12 then
set result := '四';
else
set result := '非法';
end case;
select concat('您输入的参数为', month, '季度为',result);
end;
循环语句
while
repeat

loop

游标

但是这个有问题,while true是一直循环
可以使用Handler处理
条件处理程序Handler

刚才的程序多声明一句handler语句就可以成功退出循环
存储函数
存储函数不如存储过程,存储函数必须有返回值