mysql函数
创建语法
create function 函数名(参数列表) returns 返回类型
begin
函数体
end
实例
create function getCount() returns int
begin
declare c int default 0;
select count(*) into c
from student;
return c;
end
调用方法
select 函数名(参数列表)
select getCount();
实例
create function myAdd(num int, num2 int) returns int
begin
declare c int default 0;
set c = num + num2;
return c;
end
调用方法
select myAdd(5,8);
查看函数
show create function myAdd;
删除函数
drop function myAdd;

浙公网安备 33010602011771号