14.12.5 Reclaiming Disk Space with TRUNCATE TABLE
To reclaim operating system disk space when an InnoDB table, the table must be stored in its own file. For a table to be stored in its own file, innodb_file_per_table must enabled when the table is created. Additionally, there cannot be a constraint between the table being truncated and other tables, otherwise the TRUNCATE TABLE operation fails. A foreign key constraint between two columns in the same table, however, is permitted.
When a table is truncated, it is dropped and re-created in a new .ibd file, and the freed space is returned to the operating system. This is in contrast to truncating InnoDB tables that are stored within the InnoDB (tables created when innodb_file_per_table=OFF) and tables stored in shared , where only InnoDB can use the freed space after the table is truncated.
The ability to truncate tables and return disk space to the operating system also means that can be smaller. Truncating tables that are stored in the system tablespace (tables created when innodb_file_per_table=OFF) or in a general tablespace leaves blocks of unused space in the tablespace.
© 2025 Oracle
Licensed under the GPLv2 License.