1.44. SQLite Vacuum

发布时间 :2025-10-25 12:31:12 UTC      

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 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

The following is issued to the entire database at the command prompt VACUUM Syntax for the command:

$sqlite3 database_name "VACUUM;"

You can also visit the SQLite Run at the prompt VACUUM , as follows:

sqlite> VACUUM;

You can also run it on a specific table VACUUM , as follows:

sqlite> VACUUM table_name;

1.44.2. Automatic VACUUM (Auto-VACUUM)

SQLite’s 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.

In the SQLite prompt, you can enable / disable it through the following compilation 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

You can run the following command from a command prompt to check auto-vacuum Set up:

$sqlite3 database_name "PRAGMA auto_vacuum;"

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.