当前位置:网站首页>【mysql学习笔记28】存储函数
【mysql学习笔记28】存储函数
2022-07-01 07:30:00 【yqs_281876918】
存储函数和存储过程十分类似,详见:【mysql学习笔记27】存储过程
存储函数有返回值,且参数只能是in类型
语法:
CREATE FUNCTION 函数名([参数列表])
RETURNS type [characteristic...]
BEGIN
--- SQL语句
RETURN ...;
END;
characteristic(特性):
- DETERMINISTIC:相同的输入参数总是产生相同的结果
- NO SQL:不包含SQL语句
- READS SQL DATA:包含查询语句但是不包含写入语句
例子
--- 返回从1到n的累加值
create function sum(n int)
returns int deterministic
begin
declare total int default 0;
while n>0 do
set total:=total+n;
set n:=n-1;
end while;
return total;
end;
边栏推荐
猜你喜欢

Todolist classic case ①

Minecraft 1.16.5模组开发(五十一) 方块实体 (Tile Entity)
![[network planning] (I) hub, bridge, switch, router and other concepts](/img/7b/fcef37496517c854ac1dbfb35fa3f4.png)
[network planning] (I) hub, bridge, switch, router and other concepts

关于图灵测试和中文屋Chinese room的理解

2022制冷与空调设备运行操作国家题库模拟考试平台操作

Illusory and simple screen raindrop post-processing effect

Image style migration cyclegan principle

她就是那个「别人家的HR」|ONES 人物

TodoList经典案例①

北漂程序员深夜emo发帖求助:女朋友走了我很孤独 ......
随机推荐
【目标检测】目标检测界的扛把子YOLOv5(原理详解+修炼指南)
C# Newtonsoft. Use of job in JSON
How to choose a product manager course when changing to a product manager?
[microservice openfeign] feign's log record
Is the account opening of GF Securities safe and reliable? How to open GF Securities Account
微软宣布开源 (GODEL) 语言模型聊天机器人
Jax's deep learning and scientific computing
Minecraft 1.16.5 module development (51) tile entity
Why are so many people turning to product managers? What is the development prospect of product manager?
浏览器本地存储
Those high-frequency written tests and interview questions in [Jianzhi offer & Niuke 101] - linked list
如何让两融交易更极速
Reply and explanation on issues related to "online training of network security education in 2022"
Kdtree notes
2022 test questions and mock examinations for main principals of hazardous chemicals business units
[R language] two /n data merge functions
【剑指offer&牛客101】中那些高频笔试,面试题——链表篇
Apple account password auto fill
Oracle创建自增id
How to enter the Internet industry and become a product manager? How to become a product manager without project experience?