函数

存储过程:可以有0个返回,也可以有多个返回

函数:只能有一个返回

creat function 函数名(参数列表)return 返回类型

begin

  函数体

end

参数列表:参数名 参数类型

函数体肯定有return语句,没有会报错

调用

select 函数名(参数列表)

#返回公司的员工个数

create function myfi() returns int

begin

  declare c int default 0; #定义变量

  select count(*) into c#赋值

  from employees;

  return c;

end $

sellect myfi()$

查看

show create function 函数名 ;

删除

drop function 函数名;

posted @ 2022-12-18 20:46  平凡的柳先生  阅读(18)  评论(0)    收藏  举报