How to vacuum sqlite database?

meghalee picture meghalee · Aug 8, 2013 · Viewed 39.7k times · Source

I want to know how to vacuum sqlite database. I tried a syntax MANUAL VACUUM command for the whole database from command prompt:

 $sqlite3 database_name "VACUUM;";

But it's giving error as:

near "database_name": syntax error.

and also AUTO VACUUM:

PRAGMA auto_vacuum = INCREMENTAL;

And tried it for a particular table as:

VACUUM table_name;

But no result.

Answer

SHANK picture SHANK · Aug 8, 2013

You don't to specify the table name in the syntax. Only VACUUM works.

Also, it will clean the main database only and not any attached database files.

For more info, refer to the SQLite documentation.