Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the use of SQLite's VACUUM command

Shulou Source: shulou.com Published: 2022-06-01 17:27:09 09月18日 Update

Most people do not understand the knowledge of this article "what is the use of SQLite's VACUUM command", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this article, "what is the use of SQLite's VACUUM command?"

SQLite's VACUUM 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.

Manual VACUUM

Here is the syntax for issuing the VACUUM command against the entire database from a command prompt:

$sqlite3 database_name "VACUUM;"

You can also run VACUUM from the SQLite prompt, as follows:

Sqlite > VACUUM

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

Sqlite > VACUUM table_name; automatic VACUUM (Auto-VACUUM)

SQLite's Auto-VACUUM is different from VACUUM in that it simply moves free pages to the end of the database, thereby reducing the database size. By doing so, it can obviously fragment the database, while VACUUM is anti-fragmented. So Auto-VACUUM will only make the database smaller.

In the SQLite prompt, you can enable / disable Auto-VACUUM for SQLite by running the following compilation:

Sqlite > PRAGMA auto_vacuum = NONE;-- 0 means disable auto vacuumsqlite > PRAGMA auto_vacuum = INCREMENTAL;-- 1 means enable incremental vacuumsqlite > PRAGMA auto_vacuum = FULL;-- 2 means enable full auto vacuum

You can check the auto-vacuum settings by running the following command from a command prompt:

The above sqlite3 database_name "PRAGMA auto_vacuum;" is about the content of this article "what is the use of SQLite's VACUUM command". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Tags: Data database command content prompt prompt run file article knowledge fragment free article face original obvious not much value copy just Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Apple Shulou Information Shulou Technology Shulou Tech Info