Search code examples
mysqlrenameprocedure

Rename a mysql procedure


Does anyone know what is the syntax for renaming a mysql stored procedure/function? Or is this even supported in MySQL? I've been googling this for several minutes...


Solution

  • try this

     UPDATE `mysql`.`proc`
    SET name = '<new_proc_name>',
    specific_name = '<new_proc_name>'
    WHERE db = '<database>' AND
      name = '<old_proc_name>';
    

    Also note: If have granted privileges to users for this procedure you will need to update the procedure name in procs_priv as well.

    UPDATE `mysql`.`procs_priv`
    SET Routine_name = '<new_proc_name>'
    WHERE Db = '<database>' AND
      Routine_name = '<old_proc_name>';
     FLUSH PRIVILEGES;
    

    Source: MySQL Forums :: Newbie :: Rename Stored Procedure Syntax