<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="drop-table">
      </a>
      15.1.32 DROP TABLE Statement
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045183342992">
  </a>
  <a class="indexterm" name="idm46045183341920">
  </a>
  <a class="indexterm" name="idm46045183340432">
  </a>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa8635500"><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 punctuation">[</span><span class="token keyword">TEMPORARY</span><span class="token punctuation">]</span> <span class="token keyword">TABLE</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">tbl_name</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">tbl_name</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token punctuation">[</span><span class="token keyword">RESTRICT</span> <span class="token operator">|</span> <span class="token keyword">CASCADE</span><span class="token punctuation">]</span></code></pre>
  </div>
  <p>
   <a class="link" href="drop-table.html" title="15.1.32 DROP TABLE Statement">
    <code class="literal">
     DROP TABLE
    </code>
   </a>
   removes one or more
      tables. You must have the
   <a class="link" href="privileges-provided.html#priv_drop">
    <code class="literal">
     DROP
    </code>
   </a>
   privilege for each table.
  </p>
  <p>
   <span class="emphasis">
    <em>
     Be careful
    </em>
   </span>
   with this statement! For each
      table, it removes the table definition and all table data. If the
      table is partitioned, the statement removes the table definition,
      all its partitions, all data stored in those partitions, and all
      partition definitions associated with the dropped table.
  </p>
  <p>
   Dropping a table also drops any triggers for the table.
  </p>
  <p>
   <a class="link" href="drop-table.html" title="15.1.32 DROP TABLE Statement">
    <code class="literal">
     DROP TABLE
    </code>
   </a>
   causes an implicit
      commit, except when used with the
   <code class="literal">
    TEMPORARY
   </code>
   keyword. See
   <a class="xref" href="implicit-commit.html" title="15.3.3 Statements That Cause an Implicit Commit">
    Section 15.3.3, “Statements That Cause an Implicit Commit”
   </a>
   .
  </p>
  <div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Important
   </div>
   <p>
    When a table is dropped, privileges granted specifically for the
        table are
    <span class="emphasis">
     <em>
      not
     </em>
    </span>
    automatically dropped. They
        must be dropped manually. See
    <a class="xref" href="grant.html" title="15.7.1.6 GRANT Statement">
     Section 15.7.1.6, “GRANT Statement”
    </a>
    .
   </p>
  </div>
  <p>
   If any tables named in the argument list do not exist,
   <a class="link" href="drop-table.html" title="15.1.32 DROP TABLE Statement">
    <code class="literal">
     DROP TABLE
    </code>
   </a>
   behavior depends on
      whether the
   <code class="literal">
    IF EXISTS
   </code>
   clause is given:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Without
      <code class="literal">
       IF EXISTS
      </code>
      , the statement fails with
          an error indicating which nonexisting tables it was unable to
          drop, and no changes are made.
     </p>
    </li>
    <li class="listitem">
     <p>
      With
      <code class="literal">
       IF EXISTS
      </code>
      , no error occurs for
          nonexisting tables. The statement drops all named tables that
          do exist, and generates a
      <code class="literal">
       NOTE
      </code>
      diagnostic
          for each nonexistent table. These notes can be displayed with
      <a class="link" href="show-warnings.html" title="15.7.7.42 SHOW WARNINGS Statement">
       <code class="literal">
        SHOW WARNINGS
       </code>
      </a>
      . See
      <a class="xref" href="show-warnings.html" title="15.7.7.42 SHOW WARNINGS Statement">
       Section 15.7.7.42, “SHOW WARNINGS Statement”
      </a>
      .
     </p>
    </li>
   </ul>
  </div>
  <p>
   <code class="literal">
    IF EXISTS
   </code>
   can also be useful for dropping
      tables in unusual circumstances under which there is an entry in
      the data dictionary but no table managed by the storage engine.
      (For example, if an abnormal server exit occurs after removal of
      the table from the storage engine but before removal of the data
      dictionary entry.)
  </p>
  <p>
   The
   <code class="literal">
    TEMPORARY
   </code>
   keyword has the following
      effects:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      The statement drops only
      <code class="literal">
       TEMPORARY
      </code>
      tables.
     </p>
    </li>
    <li class="listitem">
     <p>
      The statement does not cause an implicit commit.
     </p>
    </li>
    <li class="listitem">
     <p>
      No access rights are checked. A
      <code class="literal">
       TEMPORARY
      </code>
      table is visible only with the session that created it, so no
          check is necessary.
     </p>
    </li>
   </ul>
  </div>
  <p>
   Including the
   <code class="literal">
    TEMPORARY
   </code>
   keyword is a good way
      to prevent accidentally dropping non-
   <code class="literal">
    TEMPORARY
   </code>
   tables.
  </p>
  <p>
   The
   <code class="literal">
    RESTRICT
   </code>
   and
   <code class="literal">
    CASCADE
   </code>
   keywords do nothing. They are permitted to make porting easier
      from other database systems.
  </p>
  <p>
   <a class="link" href="drop-table.html" title="15.1.32 DROP TABLE Statement">
    <code class="literal">
     DROP TABLE
    </code>
   </a>
   is not supported with
      all
   <a class="link" href="innodb-parameters.html#sysvar_innodb_force_recovery">
    <code class="literal">
     innodb_force_recovery
    </code>
   </a>
   settings. See
   <a class="xref" href="forcing-innodb-recovery.html" title="17.20.3 Forcing InnoDB Recovery">
    Section 17.20.3, “Forcing InnoDB Recovery”
   </a>
   .
  </p>
  <a class="indexterm" name="idm46045183301680">
  </a>
 </div>
 <br/>
</div>
