Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in SQL by (55.6k points)

Can anyone explain the stored procedure in MySQL?

1 Answer

0 votes
by (119k points)

In MySQL, a Stored Procedure is a set of SQL codes that you can write and save that allows us to reuse the code whenever needed without having to rewrite it. Hence, if you have SQL queries that you use regularly then you can save it as a stored procedure. You just have to call the procedure for execution when required.

In short, if you have a SQL query that you need to run multiple times on a regular basis, save that as a stored procedure and use the EXEC command to reuse it.

Here is how you can create a stored procedure in MySQL:

CREATE PROCEDURE procedure_name

AS

sql_statement

GO;

You can use the following EXEC command to reuse a stored procedure:

EXEC procedure_name;

If you want to learn MySQL from top professionals, then check out this SQL Course by Intellipaat.

Also, watch this video on MySQL:

Related questions

Browse Categories

...