当前位置:网站首页>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语言课设图书信息管理系统(大作业)
- Summary of wechat official account embedded program to jump to wechat
- Design of sales management system for C language course (big homework)
- MySQL learning
- 脏读、幻读和不可重复读
- DSBridge
- ManageEngine Zhuohao helps you comply with ISO 20000 standard (IV)
- 存储过程学习笔记
- Camouflage request header Library: Anti useragent
- Resttemplate use
猜你喜欢

图解事件坐标screenX、clientX、pageX, offsetX的区别

Embedded system
![[ManageEngine Zhuohao] helps Julia college, the world's top Conservatory of music, improve terminal security](/img/fb/0a9f0ea72efc4785cc21fd0d4830c2.png)
[ManageEngine Zhuohao] helps Julia college, the world's top Conservatory of music, improve terminal security

Picture server project test
![[ITSM] what is ITSM and why does it department need ITSM](/img/e1/85b5f00f124829b6a6b40c5cf621bd.png)
[ITSM] what is ITSM and why does it department need ITSM

Student attendance system for C language course (big homework)
![[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

嵌入式系统

Promise
![[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
随机推荐
网络爬虫
Software engineering review
C language course set up salary management system (big homework)
@Transactional的传播属性REQUIRES_NEW深入理解
第五章 输入/输出(I/O)管理
如果我在广州,到哪里开户比较好?究竟网上开户是否安全么?
[unity shader stroke effect _ case sharing first]
Promise
Idea easy to use plug-in summary!!!
[wechat applet] to solve button, input and image components
Requests module (requests)
mysql约束学习笔记
[automatic operation and maintenance] what is the use of the automatic operation and maintenance platform
微信公众号内嵌跳转微信小程序方案总结
Draw a directed graph based on input
C language course set up property fee management system (big work)
DSBridge
Is the account opening of Huafu securities safe and reliable? How to open Huafu securities account
If I am in Guangzhou, where can I open an account? Is it safe to open an account online?
C语言课设工资管理系统(大作业)