Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of SQLite's VACUUM command

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report