Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
[Solved] SQLite - Compact and Optimize your database, using VACUUM, in Lazarus Pascal
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter
November 23, 2013 1:08 PM
A SQLite database can be rebuild (and therefor optimized and defragmented) with the VACUUM SQL statement.
Executing this statement requires that you cannot really work with your usual database components.
A little trick that does the job:
uses sqlite3ds;
...
var dbVacuum : TSqlite3Dataset;
...
Connection.Close; // your TSQL3Connection
dbVacuum := TSqlite3Dataset.Create(nil);
dbVacuum.FileName:=Connection.DatabaseName;
dbVacuum.ExecSQL('VACUUM;');
dbVacuum.Free;
Connection.Open;
...