当前位置:网站首页>存储过程学习笔记
存储过程学习笔记
2022-07-01 06:21:00 【小美元】
函数
自己定义的
存储过程
相对于函数可以没有返回值,存储过程存储函数预先存储在mysql的服务器上边,而且预先编译好了
存储过程:
没有参数
只有in类型(有参数无返回)
只有out类型(无参数有返回)
有in和out类型的参数(有参数有返回)
如果自己创建的时候没有指明默认就是in类型
存储过程
characteristics:指明存储过程中带的约束
language sql:指明存储过程行为的结果是否确定
sql security:指明存储过程的权限
delimit $ 代替封号表示结束
存储过程的创建
delimiter //
CREATE PROCEDURE show_max_salary()
BEGIN
SELECT MAX(salary) FROM emp;
END //
delimiter ;
存储过程的调用
CALL show_max_salary
存储过程带参数的创建调用
elimiter //
CREATE PROCEDURE show_min_salary(OUT ms DOUBLE)
BEGIN
SELECT min(salary) INTO ms
FROM emp;
END //
delimit ;
call show_min_salary(@ms);
SELECT @ms
存储过程带参数的调用2
delimiter //
CREATE procedure show_some_one_salary (IN empname VARCHAR(20))
BEGIN
SELECT salary FROM emp WHERE last_name = empname;
END //
delimiter ;
调用方式1
call show_some_one_salary(“abel”)
调用方式2
set @empname = ‘Abel’;
call show_some_one_salary(@empname);
存储过程带参数的创建与调用3
delimiter //
CREATE PROCEDURE show_someone_salary(IN empname varchar(20),OUT empsalary DECIMAL(10,2))
BEGIN
SELECT salary INTO empsalary FROM emp WHERE last_name = empname;
END //
delimiter ;
SET @empname = "abel";
call show_someone_salary (@empname,@empsalary);
SELECT @empsalary
存储过程inout3
delimiter $
CREATE procedure show_mgr_name(inout empname VARCHAR(25))
BEGIN
SELECT last_name INTO empname FROM emp
WHERE employee_id =
(SELECT manager_id FROM emp WHERE last_name = empname);
end $
delimiter ;
set @empname := "abel";
call show_mgr_name(@empname);
SELECT @empname
ps:在使用存储过程的时候由于不能调试因此错误难以排查
边栏推荐
- JDBC connection pool
- What is a port scanning tool? What is the use of port scanning tools
- IT服务管理(ITSM)在高等教育领域的应用
- ManageEngine卓豪助您符合ISO 20000标准(四)
- C语言课设销售管理系统设计(大作业)
- How did ManageEngine Zhuohao achieve the goal of being selected into Gartner Magic Quadrant for four consecutive years?
- 【自动化运维】自动化运维平台有什么用
- Uniapp tree level selector
- Pit of kotlin bit operation (bytes[i] and 0xff error)
- How does the port scanning tool help enterprises?
猜你喜欢

【ManageEngine卓豪 】助力世界顶尖音乐学院--茱莉亚学院,提升终端安全

IT服务管理(ITSM)在高等教育领域的应用

async 与 await

Teach you how to implement a deep learning framework

DHT11 temperature and humidity sensor

High order binary balanced tree

How did ManageEngine Zhuohao achieve the goal of being selected into Gartner Magic Quadrant for four consecutive years?
![[ManageEngine Zhuohao] what is network operation and maintenance management and what is the use of network operation and maintenance platform](/img/a4/b1476515260e3af0ca0dcc031deb98.png)
[ManageEngine Zhuohao] what is network operation and maintenance management and what is the use of network operation and maintenance platform

One of the characteristic agricultural products that make Tiantou village, Guankou Town, Xiamen into a "sweet" village is

手把手教你实现一个深度学习框架...
随机推荐
JMM details
【ManageEngine卓豪】助力黄石爱康医院实现智能批量化网络设备配置管理
Make: g++: command not found
SQL语句
Golang panic recover custom exception handling
[ManageEngine Zhuohao] helps Julia college, the world's top Conservatory of music, improve terminal security
C how to print out the original array
Ant new village is one of the special agricultural products that make Tiantou village in Guankou Town, Xiamen become Tiantou village
【ManageEngine卓豪】局域网监控的作用
[leetcode] day91- duplicate elements exist
Using Baidu map to query national subway lines
MongoDB:一、MongoDB是什么?MongoDB的优缺点
子类调用父类的同名方法和属性
ABP 学习解决方案中的项目以及依赖关系
【企业数据安全】升级备份策略 保障企业数据安全
json模块
Movable mechanical wall clock
手把手教你实现一个深度学习框架...
端口扫描工具是什么?端口扫描工具有什么用
高阶-二叉平衡树