存储过程
drop procedure if exists dcs30;-- 删除存储过程 如果存在dcs30
create procedure dcs30(i int)-- 创建存储过程,命名为dcs30()
begin #开始
#写相关的sql语句结合,需要重复执行的多条sql语句
declare n int default(select count(*) from mm);
-- 定义一个变量 n 类型为int,默认值为(统计mm表的行数)
declare m int default '';
-- 定义一个变量 m int类型,默认值为 空
declare o int default (select max(score) from mm);
-- 注意定义变量的sql语句必须要写在存储过程中所有的sql语句的最前面
drop table if exists mm;-- 删除表 如果存在mm表
end;结束
if:if判断的多分支,注意有多少个if就要有多少个end if;
|