Home >Database >Mysql Tutorial >What is mysql stored procedure tutorial
mysql stored procedure tutorial: First, right-click [Create Stored Procedures] in the [Stored Procedures] menu of the test database; then enter the relevant code in the create stored procedure interface; finally click [Apply] to create the stored procedure. Can.
More related free learning recommendations: mysql tutorial(video)
mysql stored procedure tutorial:
1. Create a table
1) Open the mysql graphical management tool [MySQL Workbench 6.3 CE] and log in to the mysql database
2) On the [Tables] menu of the [test] test database (an empty database created by yourself, you can use a specific database in the actual scenario), right-click and select [Create Table]
3 ) In the new table interface, enter the table name, remarks, add columns, and click the [Apply] button to complete the creation of the table
2. Insert test data
1) Select the test database, this step is optional (because the sql statements of mysql all need to be prefixed with the database name)
2) Click the first icon menu at the top of the menu [Create a new tab...】
3) In the sql statement window, enter the insert statement and query statement
4) Click the lightning icon above the sql window to execute the sql statement
3. Create stored procedures
1) Right-click [Create Stored Procedures] in the [Stored Procedures] menu of the test database
2) In the creation stored procedure interface, enter the code as shown in the figure (although there is an input parameter str, but it is not used. You can use this variable directly in the stored procedure)
3) Click [Apply] Create a stored procedure and click [Apply] in the pop-up window
4. Execute the stored procedure
1) Call the stored format [call new_procedure('haha');] in the SQL window
A) call is a necessary command to call the stored procedure
B) new_procedure is the name of the stored procedure to be called
C) ('haha') is the parameter passed into the stored procedure
2) If an error "safe update mode" is reported when executing the stored procedure, modify the data Update the schema, and then execute the stored procedure
SET SQL_SAFE_UPDATES = 0;
5. Modify the stored procedure
1) In the name of the stored procedure to be modified Right-click and select [Alter Stored Procedure...]
2) In the modified stored procedure interface, directly modify it and apply
#6. Delete stored procedures
Right-click on the name of the stored procedure to be deleted and select [Drop Stored Procedure...]
The above is the detailed content of What is mysql stored procedure tutorial. For more information, please follow other related articles on the PHP Chinese website!