Create, Delete, and Alter a Stored Procedure
Explore how to create, execute, and delete stored procedures in SQL. Learn the use of CREATE PROCEDURE, DROP PROCEDURE, and the importance of delimiters. Understand handling procedure modifications by recreating them.
We'll cover the following...
Create, Alter, and Delete a Stored Procedure
To create a stored procedure we use the CREATE PROCEDURE statement. CREATE PROCEDURE keywords are followed by the procedure name. We can also specify parameters to our procedure as a comma separated list withing parenthesis after the procedure name. The body of the stored procedure is enclosed with in the BEGIN and END keywords.
In order to delete a stored procedure, the ALTER ROUTINE privilege is a must. The DROP PROCEDURE statement deletes a stored procedure from the database. It can be used with the optional IF EXISTS clause.
Syntax
DELIMITER **
CREATE PROCEDURE procedure_name( parameter_list )
BEGIN
procedure_body
END**
DELIMITER ; ...