一组已经编译好的sql语句集合。
create procedure 存储过程名(参数列表) begin 存储过程 end;
创建
create procedure getStudent(in username varchar(20)) begin select * from student where `name` = username; end
调用语法
call getStudent('胡勇健');
创建
create procedure getClassName(in username varchar(20),out className varchar(50)) begin select class.`name` into className from student inner join class on class.id=student.class_id where student.`name` = username; end
调用
set @username = '胡勇健'; call getClassName(@username,@className); select @classname;
show create procedure getStudent;
drop procedure getStudent;