In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
I don't know if you know anything about similar articles about how Mysql stored procedures start from zero. Today, I'm here to tell you a little bit about it. If you are interested, let's take a look at the text. I'm sure you'll get something after seeing how Mysql stored procedures start from 0.
1. First of all, you have to understand that mysql is also a language, and it can also write programs and support logical judgment, if,elseif,else,switch,while and so on.
2. Mysql assigns the value operation of a variable: set @ a = 1; check that the variable is select @ a
3. When you create a stored procedure, you have to select the database of Mysql before you can operate it, such as creating a
(1) create procedure hanshuming () / / method body: select concat (@ a world')
Concat is a link string, set @ a = "Hello"
(2) the call is call hanshuming ()
4. a small example of a simple entry-level stored procedure
Mysql > DELIMITER / first you need to escape to prevent mysql from executing your statement as a sql statement
Mysql > CREATE PROCEDURE proc1-- proc1 stored procedure name
-> (IN parameter1 INTEGER)
-> BEGIN
-> DECLARE variable1 CHAR (10);-- declare is a named variable
-> IF parameter1 = 17 THEN
-> SET variable1 = 'birds'
-> ELSE
-> SET variable1 = 'beasts'
-> END IF
-> INSERT INTO table1 VALUES (variable1)
-> END
-> / /
Mysql > DELIMITER
5. View the stored procedures under the current database
(1) the show procedure status where db=' database name'G;-G means formatting
(2) View the details of the current stored procedure
Show create procedure database name. Stored procedure name G
(3) Delete stored procedures
Drop procedure sp_name-name of the stored procedure
DROP PROCEDURE-delete everything, don't use it easily
6. The defined variable is only used in the stored procedure, and the excess is gone. The following figure is an example, that is, it is gone after end.
7. Operation of inout
When you call this stored procedure, you can't put the data directly in the method, you have to set the value of the variable, and then put the variable in.
If you put it directly, you will report an error.
It should be called like this
After reading this article on how to start Mysql stored procedures from 0, what do you think? If you want to know more about it, you can continue to follow our industry information section.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
-- show blocking SPIDS and SQLSELECT Blocked.Session_ID AS Blocked_Session_ID, B
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.