Posts Tagged ‘storage engines’

How to truncate an ARCHIVE table

Friday, March 9th, 2012 | Life, Tech

Archive is a cool MySQL storage engine designed for fast inserts. In fact, it’s so optimised for this that it actually only supports INSERT and SELECT – you can’t run UPDATE or DELETE commands against it at all.

This is a problem when developing though, as you’ll often want to empty out the table and start again. But because it doesn’t support delete operations, it won’t actually let you truncate the table! So to answer the question posed in the article title – you can’t.

Therefore, you have two options.

Firstly, you can drop the table and re-create it. This is the recommended way from MySQL, so make sure you have a copy of the table creation command handy.

The second option, the lazy hacky way if you will, is to change the table storage engine over to InnoDB or MyISAM, truncate the table, and then turn it back to ARCHIVE ;).