How to vacuum sqlite database?

假装没事ソ 提交于 2019-12-03 10:45:30

问题


I want to know how to vacuum sqlite database. I tried a syntax MANUAL VACUUM command for the whole database from command prompt:

 $sqlite3 database_name "VACUUM;";

But it's giving error as:

near "database_name": syntax error.

and also AUTO VACUUM:

PRAGMA auto_vacuum = INCREMENTAL;

And tried it for a particular table as:

VACUUM table_name;

But no result.


回答1:


You don't to specify the table name in the syntax. Only VACUUM works.

Also, it will clean the main database only and not any attached database files.

For more info, refer to the SQLite documentation.




回答2:


Give the command like this:

$sqlite3 database_name 'VACUUM;'

As a matter of fact, this is the way to do also other queries from command line:

$sqlite3 database_name 'select * from tablename;'



回答3:


Run the command:

VACUUM;

if you use DB Browser for Sqlite or

open Sqlite from command prompt:

cd C:\your_folder
C:\Users\your_user\AppData\Local\Android\Sdk\platform-tools\sqlite3.exe  -line your_db_name.db

and run

VACUUM;


来源:https://stackoverflow.com/questions/18126997/how-to-vacuum-sqlite-database

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!