Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql truncate archive table

Tags:

mysql

archive

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?

like image 275
Vilius Avatar asked Oct 06 '11 23:10

Vilius


People also ask

Does TRUNCATE drop and recreate table?

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.

Does TRUNCATE table release space in MySQL?

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.

Does TRUNCATE lock table?

TRUNCATE acquires an ACCESS EXCLUSIVE lock on each table it operates on, which blocks all other concurrent operations on the table.


2 Answers

Another workaround would be to change it to be a BLACKHOLE table, then change it back.

like image 177
Ed Marty Avatar answered Sep 28 '22 02:09

Ed Marty


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.

like image 24
Bill Karwin Avatar answered Sep 28 '22 02:09

Bill Karwin