当前位置:网站首页>Navicat premium create MySQL create stored procedure

Navicat premium create MySQL create stored procedure

2022-07-06 08:42:00 Rookie post station 2020

MySQL Stored procedures are SQL Collection of statements , For example, sometimes we may need a large string of SQL sentence , Or writing SQL You need to set the values of some variables during the statement , At this time, it is absolutely necessary to write a stored procedure .

Writing stored procedures is not an easy task , But using stored procedures can simplify operations , Steps to reduce redundancy , meanwhile , It can also reduce mistakes in the process of operation , Increase of efficiency , Therefore, you should learn to use stored procedures as much as possible .

Use Navicat Premium Tools create stored procedures , New query , Input statement , Finally, click 【 function 】

 Insert picture description here

# If there is a stored procedure with the same name, delete 
DROP PROCEDURE IF EXISTS my_test2;  

# Create stored procedure , Define names and variables .** The variable name is different from the field name , Sometimes there are inexplicable problems **
CREATE PROCEDURE my_test2(in usern VARCHAR(20),in nick VARCHAR(20))
BEGIN
	SELECT * FROM sys_user where username = usern and nickname = nick;

END

Calling stored procedure

 Insert picture description here

原网站

版权声明
本文为[Rookie post station 2020]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060841160752.html