Compress Database

Bill Norris

Active Member
Licensed User
Longtime User
My sqlite database had grown quite large. I was able to delete a number of tables that were backup copies of other tables. After the deletions, the database size had not changed at all. Is there is a function to "compress" an sqlite database?
 
If you get overwhelmed by the flow charts and diagrams in SQLite's web site as I do, here is the code. It works:
Code: Copy
Sub btnCompact_Click
   ProgressDialogShow("DATABASE IS BEING COMPACTED. STAND BY")
   SQL1.ExecNonQuery("Vacuum")   
   ProgressDialogHide
   Msgbox("DATABASE COMPACTED SUCCESSFULLY.","")
End Sub
 
Upvote 0
Databases (tables) with lots of inserts and deletes should be vacuumed regularly to reduce size, align and improve performance. I was amazed at the size reduction in my DB - several hundred meg.
 
Upvote 0
Just a word of warning, always backup the database before performing a VACUUM. Better to err on the side of caution.

Colin

If you get overwhelmed by the flow charts and diagrams in SQLite's web site as I do, here is the code. It works:
Code: Copy
Sub btnCompact_Click
   ProgressDialogShow("DATABASE IS BEING COMPACTED. STAND BY")
   SQL1.ExecNonQuery("Vacuum")   
   ProgressDialogHide
   Msgbox("DATABASE COMPACTED SUCCESSFULLY.","")
End Sub
 
Upvote 0
Back
Top