数据库自定义函数

254 阅读1分钟

默认保存位置:创建函数时所在的数据库上面

定义

delimiter //
create function f1(
n1 int,
n2 nit)
returns int 
begin 
	declare num int;
	set num = n1+n2;
	return(num);
end//
delimiter;

调用

select f1(2,2)

修改

alter function 函数名 选项;

查看

show function status; -- 返回所有自定义函数
sho0w function status like 'f%'; --过滤
show create function f1; -- 返回自定义函数的创建信息
show create function tt.f1; --指定数据库下自定义函数

删除

drop function f1;