VACUUM order cleans the principle data set by replicating its substance to an impermanent information base record and reloading the first data set document from the duplicate. This dispenses with free pages, adjusts table information to be touching, and in any case tidies up the data set record structure.
VACUUM order may change the ROWID of sections in tables that don't have an unequivocal INTEGER PRIMARY KEY. The VACUUM order just chips away at the fundamental information base. It is preposterous to expect to VACUUM a connected data set document.
VACUUM order will come up short if there is a functioning exchange. VACUUM order is a no-operation for in-memory data sets. As the VACUUM order remakes the information base record without any preparation, VACUUM can likewise be utilized to alter numerous data set explicit arrangement boundaries.
Manual VACUUM
Following is a basic language structure to give a VACUUM order for the entire data set from order brief −
$sqlite3 database_name "VACUUM;"
You can run VACUUM from SQLite fast just as follows −
sqlite> VACUUM;
You can likewise run VACUUM on a specific table as follows −
sqlite> VACUUM table_name;
Auto-VACCUM
SQLite Auto-VACUUM doesn't do likewise as VACUUM rather it just moves free pages to the furthest limit of the information base along these lines lessening the data set size. Thusly it can altogether part the information base while VACUUM guarantees defragmentation. Consequently, Auto-VACUUM simply keeps the information base little.
You can empower/incapacitate SQLite auto-vacuuming by the accompanying pragmas running at SQLite brief −
sqlite> PRAGMA auto_vacuum = NONE; -- 0 means disable auto vacuum
sqlite> PRAGMA auto_vacuum = FULL; -- 1 means enable full auto vacuum
sqlite> PRAGMA auto_vacuum = INCREMENTAL; -- 2 means enable incremental vacuum
You can run the accompanying order from the order brief to check the auto-vacuum setting −
$sqlite3 database_name "PRAGMA auto_vacuum;"