MySQL Database Stored Procedure


  • A stored procedure is a procedure that is used to store data into database and retrieve data from multiple tables.
  • A stored procedure has a name, a parameter list, and an SQL statement, which can contain many more SQL statements.
  • A stored procedure can take one or more argument that can be IN and OUT and returns a result set. By default store procedure parameters are IN.
  • Procedures and functions are stored in a system table: mysql.proc
  • Now we need a delimiter. The statement we'll use is DELIMITER // . The delimiter is the character or string of characters that you'll use to tell the mysql client that you've finished typing in an SQL statement
  • There are various queries of MySQL Procedure
  • Create Procedure
    Call Procedure
    Drop Procedure

Create Procedure

  • You should need database table to store data, So you can create table in selected database by using this query-

  • There are various queries on funtion:
  • Create PROCEDURE
  • Syntax-
    mysql>DELEMITER //
    ->CREATE PROCEDUREprocedure name(parameter1,parameter2,...parameterN)
    -> < Database query to execute >

  • Syntax-
    mysql> CALL < procedure name >
    -> //

  • Syntax-
    mysql> DROP PROCEDURE < procedure name >
    -> //

    mysql procedure