<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="drop-procedure">
      </a>
      15.1.29 DROP PROCEDURE and DROP FUNCTION Statements
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045183404224">
  </a>
  <a class="indexterm" name="idm46045183403184">
  </a>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa64271389"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">DROP</span> {<span class="token keyword">PROCEDURE</span> <span class="token operator">|</span> <span class="token keyword">FUNCTION</span>} <span class="token punctuation">[</span><span class="token keyword">IF</span> <span class="token keyword">EXISTS</span><span class="token punctuation">]</span> <em class="replaceable">sp_name</em></code></pre>
  </div>
  <p>
   These statements are used to drop a stored routine (a stored
      procedure or function). That is, the specified routine is removed
      from the server. (
   <code class="literal">
    DROP FUNCTION
   </code>
   is also used to
      drop loadable functions; see
   <a class="xref" href="drop-function-loadable.html" title="15.7.4.2 DROP FUNCTION Statement for Loadable Functions">
    Section 15.7.4.2, “DROP FUNCTION Statement for Loadable Functions”
   </a>
   .)
  </p>
  <p>
   To drop a stored routine, you must have the
   <a class="link" href="privileges-provided.html#priv_alter-routine">
    <code class="literal">
     ALTER ROUTINE
    </code>
   </a>
   privilege for it. (If
      the
   <a class="link" href="server-system-variables.html#sysvar_automatic_sp_privileges">
    <code class="literal">
     automatic_sp_privileges
    </code>
   </a>
   system variable is enabled, that privilege and
   <a class="link" href="privileges-provided.html#priv_execute">
    <code class="literal">
     EXECUTE
    </code>
   </a>
   are granted automatically
      to the routine creator when the routine is created and dropped
      from the creator when the routine is dropped. See
   <a class="xref" href="stored-routines-privileges.html" title="27.2.2 Stored Routines and MySQL Privileges">
    Section 27.2.2, “Stored Routines and MySQL Privileges”
   </a>
   .)
  </p>
  <p>
   In addition, if the definer of the routine has the
   <a class="link" href="privileges-provided.html#priv_system-user">
    <code class="literal">
     SYSTEM_USER
    </code>
   </a>
   privilege, the user
      dropping it must also have this privilege.
  </p>
  <p>
   The
   <code class="literal">
    IF EXISTS
   </code>
   clause is a MySQL extension. It
      prevents an error from occurring if the procedure or function does
      not exist. A warning is produced that can be viewed with
   <a class="link" href="show-warnings.html" title="15.7.7.42 SHOW WARNINGS Statement">
    <code class="literal">
     SHOW WARNINGS
    </code>
   </a>
   .
  </p>
  <p>
   <a class="link" href="drop-function.html" title="15.1.26 DROP FUNCTION Statement">
    <code class="literal">
     DROP FUNCTION
    </code>
   </a>
   is also used to drop
      loadable functions (see
   <a class="xref" href="drop-function-loadable.html" title="15.7.4.2 DROP FUNCTION Statement for Loadable Functions">
    Section 15.7.4.2, “DROP FUNCTION Statement for Loadable Functions”
   </a>
   ).
  </p>
 </div>
 <br/>
</div>
