I have a table with the archive storage engine and I would like to clear it. Neither delete
, nor truncate
will work because of the engine definition. But is there any other way than dropping the whole table an recreating it?
Although TRUNCATE TABLE is similar to DELETE , it is classified as a DDL statement rather than a DML statement. It differs from DELETE in the following ways: Truncate operations drop and re-create the table, which is much faster than deleting rows one by one, particularly for large tables.
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.
TRUNCATE acquires an ACCESS EXCLUSIVE lock on each table it operates on, which blocks all other concurrent operations on the table.
Another workaround would be to change it to be a BLACKHOLE table, then change it back.
See Bug #15558 truncate doesn't clear table on archive storage engine tables
Basically, the designers wanted it to work that way. The fix to that bug was to make it return an error when you try to use truncate on a table stored with the ARCHIVE storage engine.
The only workaround is to DROP and the re-CREATE the table.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With