Stored procedures for MySQL database
Conventional
Create routine
Alter
Execute
Security
Definer
The default is to select the appropriate database when creating the stored procedure (use db_name)
Therefore, you cannot write this statement in a stored procedure while writing a stored procedure
Delimiter Client
Using the delimiter client to set the Terminator
Delimiter//
Primarily to avoid terminator conflicts with SQL statements in stored procedures
Create a program or a function
CREATE PROCEDURE | function
Learning Stored Procedures
First of all, we should learn the basics of several operations
Create, invoke, modify, delete
So, let's take a few examples to deepen the impression.
Delete a stored procedure
Drop procedure | function if exists //
View a stored procedure
Create Procedure | function db_name //
View details of a stored procedure
procedure | function like ' Proname ' //
Use case one, write a stored procedure that has a simple query function
When using the delimiter client, it will be processed in the form of//.
Then be sure to call the same form when you create and invoke the stored procedure.
Either always use it, or always use//
1. Create a stored procedure
// Create procedure int )beginSelectcount(* into from member; End //
2. Call the stored procedure
// Call Simplepro (@a//Select@a//
When calling a stored procedure, specify an alias for the output to invoke.
Where A is just an alias of the specified
Use case two, write a simple storage function
1. Create a storage function
// Create function Char (returnschar()return concat (' Hello, '" ! ' )//
2. Call storage function
// Select Hello ('world! ' //
Stored procedures for MySQL database (i)