How to create a Stored Procedure in MySQL? | Eklavya Online

How to create a Stored Procedure in MySQL?

A stored procedure is a group of SQL statements that we save in the database. The SQL queries, including INSERT, UPDATE, DELETE, etc. can be a part of the stored procedure. A procedure allows us to use the same code over and over again by executing a single statement. It stores in the database data dictionary.

We can create a stored procedure using the below syntax:

CREATE PROCEDURE procedure_name [ (parameter datatype [, parameter datatype]) ]
Body_section of SQL statements
This statement can return one or more value through parameters or may not return any result. The following example explains it more clearly:

CREATE PROCEDURE get_student_info()
SELECT * FROM Student_table;