**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 函數名稱;
```