The CREATE PROCEDURE Statement : Procedure « Procedure Function « MySQL Tutorial






Here is the syntax:

CREATE [DEFINER = { user | CURRENT_USER }]
    PROCEDURE sp_name ([proc_parameter[,...]])
    [characteristic ...] Valid SQL procedure statement

proc_parameter:
    [ IN | OUT | INOUT ] param_name type

characteristic:
    LANGUAGE SQL
  | [NOT] DETERMINISTIC
  | { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
  | SQL SECURITY { DEFINER | INVOKER }
  | COMMENT 'string'

By default, the procedure is associated with the default database.

To associate explicitly with a given database, specify the name as db_name.sp_name.

The name must be followed by parentheses.

If the database is not provided, MySQL creates the procedure in the current database or gives a No database selected error.

Procedure names can be up to 64 characters long.

If you must have a procedure with the same name as a MySQL function, putting a space between the name and the parentheses will help MySQL differentiate between the two.









11.5.Procedure
11.5.1.The CREATE PROCEDURE Statement
11.5.2.You can set parameters for a stored procedure
11.5.3.Using an OUT parameter.
11.5.4.The stored procedure characteristics include a number of options for how the stored procedure behaves.
11.5.5.Creating a Single-Statement Procedure
11.5.6.Calling a Single-Statement Procedure
11.5.7.Creating a Multistatement Stored Procedure
11.5.8.The ALTER statement lets you change the characteristics of a stored procedure
11.5.9.To remove a stored procedures, use the DROP statement
11.5.10.ALTER PROCEDURE and ALTER FUNCTION Syntax
11.5.11.DROP PROCEDURE and DROP FUNCTION Syntax
11.5.12.Stored Procedure Permissions