<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="drop-role">
      </a>
      15.7.1.4 DROP ROLE Statement
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045174078112">
  </a>
  <a class="indexterm" name="idm46045174077040">
  </a>
  <a class="indexterm" name="idm46045174075552">
  </a>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa27591155"><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">ROLE</span> <span class="token punctuation">[</span><span class="token keyword">IF</span> <span class="token keyword">EXISTS</span><span class="token punctuation">]</span> <span class="token keyword"><em class="replaceable">role</em></span> <span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token keyword"><em class="replaceable">role</em></span> <span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></code></pre>
  </div>
  <p>
   <a class="link" href="drop-role.html" title="15.7.1.4 DROP ROLE Statement">
    <code class="literal">
     DROP ROLE
    </code>
   </a>
   removes one or more
        roles (named collections of privileges). To use this statement,
        you must have the global
   <a class="link" href="privileges-provided.html#priv_drop-role">
    <code class="literal">
     DROP
        ROLE
    </code>
   </a>
   or
   <a class="link" href="privileges-provided.html#priv_create-user">
    <code class="literal">
     CREATE USER
    </code>
   </a>
   privilege. When the
   <a class="link" href="server-system-variables.html#sysvar_read_only">
    <code class="literal">
     read_only
    </code>
   </a>
   system variable is enabled,
   <a class="link" href="drop-role.html" title="15.7.1.4 DROP ROLE Statement">
    <code class="literal">
     DROP
        ROLE
    </code>
   </a>
   additionally requires the
   <a class="link" href="privileges-provided.html#priv_connection-admin">
    <code class="literal">
     CONNECTION_ADMIN
    </code>
   </a>
   privilege (or
        the deprecated
   <a class="link" href="privileges-provided.html#priv_super">
    <code class="literal">
     SUPER
    </code>
   </a>
   privilege).
  </p>
  <p>
   Users who have the
   <a class="link" href="privileges-provided.html#priv_create-user">
    <code class="literal">
     CREATE USER
    </code>
   </a>
   privilege can use this statement to drop accounts that are
        locked or unlocked. Users who have the
   <a class="link" href="privileges-provided.html#priv_drop-role">
    <code class="literal">
     DROP
        ROLE
    </code>
   </a>
   privilege can use this statement only to drop
        accounts that are locked (unlocked accounts are presumably user
        accounts used to log in to the server and not just as roles).
  </p>
  <p>
   Roles named in the
   <a class="link" href="server-system-variables.html#sysvar_mandatory_roles">
    <code class="literal">
     mandatory_roles
    </code>
   </a>
   system variable
        value cannot be dropped.
  </p>
  <p>
   <a class="link" href="drop-role.html" title="15.7.1.4 DROP ROLE Statement">
    <code class="literal">
     DROP ROLE
    </code>
   </a>
   either succeeds for all
        named roles or rolls back and has no effect if any error occurs.
        By default, an error occurs if you try to drop a role that does
        not exist. If the
   <code class="literal">
    IF EXISTS
   </code>
   clause is given,
        the statement produces a warning for each named role that does
        not exist, rather than an error.
  </p>
  <p>
   The statement is written to the binary log if it succeeds, but
        not if it fails; in that case, rollback occurs and no changes
        are made. A statement written to the binary log includes all
        named roles. If the
   <code class="literal">
    IF EXISTS
   </code>
   clause is
        given, this includes even roles that do not exist and were not
        dropped.
  </p>
  <p>
   Each role name uses the format described in
   <a class="xref" href="role-names.html" title="8.2.5 Specifying Role Names">
    Section 8.2.5, “Specifying Role Names”
   </a>
   . For example:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa89582696"><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">ROLE</span> <span class="token string">'admin'</span><span class="token punctuation">,</span> <span class="token string">'developer'</span><span class="token punctuation">;</span>
<span class="token keyword">DROP</span> <span class="token keyword">ROLE</span> <span class="token string">'webapp'</span>@<span class="token string">'localhost'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   The host name part of the role name, if omitted, defaults to
   <code class="literal">
    '%'
   </code>
   .
  </p>
  <p>
   A dropped role is automatically revoked from any user account
        (or role) to which the role was granted. Within any current
        session for such an account, its adjusted privileges apply
        beginning with the next statement executed.
  </p>
  <p>
   For role usage examples, see
   <a class="xref" href="roles.html" title="8.2.10 Using Roles">
    Section 8.2.10, “Using Roles”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
