Documentation Home
MySQL 9.5 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 41.4Mb
PDF (A4) - 41.5Mb
Man Pages (TGZ) - 272.3Kb
Man Pages (Zip) - 378.3Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb


MySQL 9.5 Reference Manual  / ...  / SQL Statements  / Data Definition Statements  /  ALTER PROCEDURE Statement

15.1.9 ALTER PROCEDURE Statement

ALTER PROCEDUREproc_name [characteristic ...]characteristic: {    COMMENT 'string'  | LANGUAGE {SQL | JAVASCRIPT}  | { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }  | SQL SECURITY { DEFINER | INVOKER }  | USING([library_reference][,library_reference][, ...])}

This statement can be used to change the characteristics of a stored procedure. More than one change may be specified in anALTER PROCEDURE statement. However, you cannot change the parameters or body of a stored procedure using this statement; to make such changes, you must drop and re-create the procedure usingDROP PROCEDURE andCREATE PROCEDURE.

You must have theALTER ROUTINE privilege for the procedure. By default, that privilege is granted automatically to the procedure creator. This behavior can be changed by disabling theautomatic_sp_privileges system variable. SeeSection 27.2.2, “Stored Routines and MySQL Privileges”.

TheUSING clause is specific to stored programs written in JavaScript (seeSection 27.3, “JavaScript Stored Programs”), and allows you to specify a list of zero or more libraries to be imported by the stored procedure, causing any previous such list to be removed (just as it does withALTER FUNCTION). Possible results are listed here:

  • AUSING clause is employed, and lists one or more libraries: Following execution of theALTER PROCEDURE statement, the procedure imports only those libraries listed in theALTER FUNCTION statement; any libraries listed previously are removed from the list and no longer imported.

  • The statement includes an emptyUSING clause: All libraries previously imported are removed from the list; the function no longer imports any libraries.

  • USING is not used: No changes are made to the list of libraries specified when the procedure was created.

Examples:

  • ALTER PROCEDURE myproc USING(lib1, lib2);

    (USING with a non-empty list:) Following execution,myproc importsonly the librarieslib1 andlib2, and no other libraries.

  • ALTER PROCEDURE myproc USING();

    (USING with an empty list:) Following execution,myproc no longer imports any libraries at all.

  • ALTER PROCEDURE myproc COMMENT "This procedure was altered";

    (NoUSING clause:) The procedure continues to import the same libraries as it did before this was issued.