sqlite
Database; use; embedded relational database
vacuum
英[ˈvækjuəm] 美[ˈvækjuəm ]
n. Vacuum; blank; emptiness; clean
v. Clean with a vacuum cleaner
SQLite Vacuum command syntax
Function: The VACUUM command copies the contents of the main database to a temporary database file, then clears the main database and reloads the original database file from the copy. This eliminates free pages, arranges the data in the table to be contiguous, and cleans up the database file structure. If the table does not have an explicit integer primary key (INTEGER PRIMARY KEY), the VACUUM command may change the row ID (ROWID) of the entry in the table. The VACUUM command only works on the master database, it is not possible to use the VACUUM command on attached database files. The VACUUM command fails if there is an active transaction. The VACUUM command is an operation for any in-memory database. Because the VACUUM command recreates database files from scratch, VACUUM can also be used to modify many database-specific configuration parameters.
Syntax: $sqlite3 database_name "VACUUM;" sqlite> VACUUM; sqlite> VACUUM table_name;
SQLite Vacuum command example
SQLite 的 Auto-VACUUM 与 VACUUM 不大一样,它只是把空闲页移到数据库末尾,从而减小数据库大小。通过这样做,它可以明显地把数据库碎片化,而 VACUUM 则是反碎片化。所以 Auto-VACUUM 只会让数据库更小。 在 SQLite 提示符中,您可以通过下面的编译运行,启用/禁用 SQLite 的 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 设置: $sqlite3 database_name "PRAGMA auto_vacuum;"