sqlite3 app.db 'VACUUM;'

Category: Databases & SQL

sqlite3 app.db 'VACUUM;'

Rebuild the database to reclaim space

Rewrites the file, packing free pages left by deletes and shrinking it. VACUUM needs an exclusive lock, so run it when the app is idle. Related: .backup first.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.