**1.选择数据库**
`use 数据库名;`
**2.查询功能是否开启**
```
show variables like '%fun%';
变量名称 log_bin_trust_function_creators
```
**3.开启功能**
```
set global log_bin_trust_function_creators=1;
```
**4创建函数**
```
delimiter $$;
create function fun(a int,b int)
returns int
begin
return a+b;
end
$$;
```
**查看函数创建语句**
```
show create function 函数名称;
```
**查看库下所有函数列表**
```
select `name` from mysql.proc where db = 'STSS' and `type` = 'FUNCTION' #STSS为库的库名
```
**删除函数**
```
drop function if exists 函数名称;
```