How To Execute Stored Procedure In MySQL Workbench

Stored Procedures allow you to save SQL queries in order to run them again later. It is very convenient for SQL queries that you need to run repeatedly. Here’s how to execute stored procedure in MySQL Workbench.

 

How To Execute Stored Procedure In MySQL Workbench

Here are the steps to run stored procedure in MySQL Workbench. Let’s say you have the following SQL query.

mysql> select * from products;

 

and we create the following stored procedure get_products using the above SQL query.

mysql> DELIMITER //

mysql> CREATE PROCEDURE Get_Products()
       BEGIN
       SELECT *  FROM products;
       END //

mysql> DELIMITER ;
mysql> call get_products;
+------------+--------------------+-------+
| product_id | product_name       | price |
+------------+--------------------+-------+
|          1 | iPhone 11          |   400 |
|          2 | Samsung Galaxy A50 |   250 |
+------------+--------------------+-------+

 

Bonus Read : MySQL Get Duplicate Records

 

Let us look at how to execute stored procedure in MySQL Workbench.

 

1. Open MySQL Workbench.

 

2. Create New tab to run SQL statements.

execute stored procedure in mysql workbench

 

Bonus Read : MySQL Add Unique Constraint

 

3. Enter the SQL statements for stored procedure in your new tab.

execute stored procedure in mysql workbench

 

4. Execute the store procedure statements by clicking the ‘lightning’ icon shown below. That will call stored procedure in MySQL Workbench.

execute stored procedure in mysql workbench

Bonus Read : MySQL Stored Procedure With Parameters

 

5. Expand the stored procedure node in right pane. You should see the name of your stored procedure (get_products). If you don’t see it, then hit refresh button next to SCHEMAS

execute stored procedure in mysql workbench

 

Ubiq makes it easy to visualize data in minutes, and monitor in real-time dashboards. Try it Today!

mm

About Ubiq

Ubiq makes it easy to build dashboards, charts & reports for your business. Get insights from data. Track key metrics. Try ubiq for free!