VACUUM
The command copies the contents of the master database to a tempdb file, then empties the master database, and reloads the original database file from the replica. This eliminates free pages, arranges the data in the table as contiguous, and cleans up the database file structure.
If there is no explicit integer primary key (INTEGER PRIMARY KEY) in the table, the
VACUUM
command may change the row ID (ROWID) of the items in the table. The
VACUUM
command is only applicable to the primary database, and additional database files are impossible to use.
VACUUM
Orders.
If there is an active transaction, the The following is issued to the entire database at the command prompt You can also visit the You can also run it on a specific table SQLite’s In the SQLite prompt, you can enable / disable it through the following compilation You can run the following command from a command prompt to check
VACUUM
command fails. The
VACUUM
command is any operation for an in-memory database. Due to
VACUUM
Command to recreate the database file from scratch, so
VACUUM
It can also be used to modify many database-specific configuration parameters. 1.44.1. Manual VACUUM ¶
VACUUM
Syntax for the command:$sqlite3 database_name "VACUUM;"
SQLite
Run at the prompt
VACUUM
, as follows:sqlite> VACUUM;
VACUUM
, as follows:sqlite> VACUUM table_name;
1.44.2. Automatic VACUUM (Auto-VACUUM) ¶
Auto-VACUUM
Vs.
VACUUM
Different, it just moves free pages to the end of the database, thereby reducing the size of the database. By doing so, it can obviously fragment the database, while
VACUUM
Is anti-fragmentation. So
Auto-VACUUM
It only makes the database smaller.
SQLite
Of
Auto-VACUUM
:sqlite> PRAGMA auto_vacuum = NONE; -- 0 means disable auto vacuum
sqlite> PRAGMA auto_vacuum = INCREMENTAL; -- 1 means enable incremental vacuum
sqlite> PRAGMA auto_vacuum = FULL; -- 2 means enable full auto vacuum
auto-vacuum
Set up:$sqlite3 database_name "PRAGMA auto_vacuum;"