当前位置:网站首页>Storage function learning notes
Storage function learning notes
2022-07-01 06:35:00 【Small dollar】
Creation and call of stored procedure
Function creation 1
delimiter $
CREATE FUNCTION email_byname()
RETURNS VARCHAR(25)
DETERMINISTIC
CONTAINS SQL
READS SQL DATA
BEGIN
RETURN(SELECT email FROM emp WHERE last_name = “abel”);
END $
delimiter ;
SELECT email_byname();
Function creation 2
SET GLOBAL log_bin_trust_function_creators = 1;
delimiter //
CREATE FUNCTION email_byid(emp_id INT)
RETURNS VARCHAR(15)
BEGIN
RETURN (SELECT email FROM emp WHERE employee_id = emp_id);
END //
delimiter ;
SELECT email_byid(101);
delimiter //
CREATE FUNCTION count_byid(dept_id INT)
RETURNS INT
BEGIN
RETURN(SELECT count(*) FROM emp WHERE department_id = dept_id);
END //
delimiter ;
SET @dept_id:= 30;
SELECT count_byid(@dept_id)
The storage function must have a return value , A stored procedure may not return a value , Stored procedures are generally used for update operations , The storage function is generally used to query that the result is a value and returns . Stored procedures can have more return values
View of stored procedures and functions 、 modify 、 Delete
see
- show create function or procedure Function creation information
- show procedure status
- SELECT * FROM information_schema.Routines
WHERE routine_name = ‘email_byid’; View information about stored procedures and stored functions from this table
Modification of stored procedure functions
ALTER PROCEDURE show_max_salary
SQL SECURITY invoker
COMMENT ‘ Query maximum wage ’;
show PROCEDURE STATUS like ‘show_max_salary’
The note to modify this table is to query the maximum salary
Then view the information
Deletes stored procedures and functions
DROP FUNCTION if EXISTS connt_byid
advantage : The stored procedure is compiled when it is created , After that, it will not be compiled
The security of stored procedure is better than that of price , You can set permissions
shortcoming : Difficult to debug and extend , There's no portability , Increasing the pressure on the database in the case of high concurrency
边栏推荐
- 码力十足学量化|如何在财务报告寻找合适的财务公告
- 【微信小程序低代码开发】二,在实操中化解小程序的代码组成
- C语言课设图书信息管理系统(大作业)
- @Propagation property of transactional requires_ New in-depth understanding
- SQL学习笔记九种连接2
- Three minutes to quickly understand the whole process of website development
- Async and await
- [ManageEngine Zhuohao] use unified terminal management to help "Eurex group" digital transformation
- How did ManageEngine Zhuohao achieve the goal of being selected into Gartner Magic Quadrant for four consecutive years?
- Notes on probability theory
猜你喜欢

Embedded system
![[unity shader ablation effect _ case sharing]](/img/e3/464f1cf426e8c03ce3d538ed9cf4bc.png)
[unity shader ablation effect _ case sharing]
![[automatic operation and maintenance] what is the use of the automatic operation and maintenance platform](/img/14/756d566744d6e4a988a284c5b30130.png)
[automatic operation and maintenance] what is the use of the automatic operation and maintenance platform

C语言课设学生考勤系统(大作业)

问题:OfficeException: failed to start and connect(三)

C language course design student information management system (big homework)

C语言课设学生选修课程系统(大作业)

SQL语句

C language course set up property fee management system (big work)

NOC 设计的一些坑
随机推荐
C语言课设学生信息管理系统(大作业)
子类调用父类的同名方法和属性
启牛学堂合作的证券公司是哪家?开户安全吗?
根据输入画有向图
产品学习(三)——需求列表
产品学习(一)——结构图
Three minutes to quickly understand the whole process of website development
webapck打包原理--启动过程分析
【微信小程序低代码开发】二,在实操中化解小程序的代码组成
SQL学习笔记九种连接2
请求模块(requests)
Design of sales management system for C language course (big homework)
绕圆旋转动画组件,拿过来直接用
Find the original array for the inverse logarithm
Chapter V input / output (i/o) management
Software engineering review
lxml模块(数据提取)
【Unity Shader 描边效果_案例分享第一篇】
On whether variables are thread safe
C语言课设学生选修课程系统(大作业)