当前位置:网站首页>【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;
边栏推荐
- 2022危险化学品经营单位主要负责人试题及模拟考试
- 组件的自定义事件①
- 长路漫漫、技术作伴
- Redisson utilise la solution complète - redisson Documents officiels + commentaires (Partie 1)
- 未来互联网人才还稀缺吗?哪些技术方向热门?
- Is it safe and reliable for Huatai Securities to open an account? How to open Huatai Securities Account
- redisson使用全解——redisson官方文档+注释(中篇)
- 热烈祝贺五行和合酒成功挂牌
- Paging in servlets and JSPS
- [network planning] (I) hub, bridge, switch, router and other concepts
猜你喜欢

C# 读写自定义的Config文件

C # read and write customized config file

2022 mobile crane driver test exercises and online simulation test

【Flutter 问题系列第 72 篇】在 Flutter 中使用 Camera 插件拍的图片被拉伸问题的解决方案

Minecraft 1.16.5模组开发(五十一) 方块实体 (Tile Entity)

Why are so many people turning to product managers? What is the development prospect of product manager?

redisson使用全解——redisson官方文檔+注釋(上篇)

Huawei modelarts training alexnet model

运维管理系统,人性化操作体验

DC-4 target
随机推荐
kdtree(kd树)笔记
C# Newtonsoft. Use of job in JSON
【目标检测】目标检测界的扛把子YOLOv5(原理详解+修炼指南)
Subclasses call methods and properties of the parent class with the same name
Image style migration cyclegan principle
Is it reliable to open an account on the compass with your mobile phone? Is there any potential safety hazard
5G Massive MIMO的概念和优点总结
[image processing] image histogram equalization system with GUI interface
Is it safe and reliable for Huatai Securities to open an account? How to open Huatai Securities Account
赌上了绩效,赢了公司CTO,我要搭DevOps平台!
Todolist classic case ①
The game is real! China software cup releases a new industrial innovation competition, and schools and enterprises can participate in it jointly
iNFTnews | 从《雪崩》到百度“希壤”,元宇宙30年的16件大事
如何让两融交易更极速
We found a huge hole in MySQL: do not judge the number of rows affected by update!!!
Vscode automatically formats code according to eslint specification
AUTOSAR learning record (1) – ECUM_ Init
atguigu----脚手架--02-使用脚手架(2)
【编程强训】删除公共字符(哈希映射)+组队竞赛(贪心)
Système de gestion de l'exploitation et de l'entretien, expérience d'exploitation humanisée