<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="innodb-truncate-table-reclaim-space">
      </a>
      17.11.5 Reclaiming Disk Space with TRUNCATE TABLE
     </h3>
    </div>
   </div>
  </div>
  <p>
   To reclaim operating system disk space when
   <a class="link" href="glossary.html#glos_truncate" title="truncate">
    truncating
   </a>
   an
   <code class="literal">
    InnoDB
   </code>
   table, the table must be stored in its
      own
   <a class="link" href="glossary.html#glos_ibd_file" title=".ibd file">
    .ibd
   </a>
   file. For a table to
      be stored in its own
   <a class="link" href="glossary.html#glos_ibd_file" title=".ibd file">
    .ibd
   </a>
   file,
   <a class="link" href="innodb-parameters.html#sysvar_innodb_file_per_table">
    <code class="literal">
     innodb_file_per_table
    </code>
   </a>
   must
      enabled when the table is created. Additionally, there cannot be a
   <a class="link" href="glossary.html#glos_foreign_key" title="foreign key">
    foreign key
   </a>
   constraint
      between the table being truncated and other tables, otherwise the
   <code class="literal">
    TRUNCATE TABLE
   </code>
   operation fails. A foreign key
      constraint between two columns in the same table, however, is
      permitted.
  </p>
  <p>
   When a table is truncated, it is dropped and re-created in a new
   <code class="filename">
    .ibd
   </code>
   file, and the freed space is returned to
      the operating system. This is in contrast to truncating
   <code class="literal">
    InnoDB
   </code>
   tables that are stored within the
   <code class="literal">
    InnoDB
   </code>
   <a class="link" href="glossary.html#glos_system_tablespace" title="system tablespace">
    system tablespace
   </a>
   (tables created when
   <code class="literal">
    innodb_file_per_table=OFF
   </code>
   )
      and tables stored in shared
   <a class="link" href="glossary.html#glos_general_tablespace" title="general tablespace">
    general
      tablespaces
   </a>
   , where only
   <code class="literal">
    InnoDB
   </code>
   can use
      the freed space after the table is truncated.
  </p>
  <p>
   The ability to truncate tables and return disk space to the
      operating system also means that
   <a class="link" href="glossary.html#glos_physical_backup" title="physical backup">
    physical backups
   </a>
   can
      be smaller. Truncating tables that are stored in the system
      tablespace (tables created when
   <code class="literal">
    innodb_file_per_table=OFF
   </code>
   ) or in a general
      tablespace leaves blocks of unused space in the tablespace.
  </p>
 </div>
 <br/>
</div>
