Page 1 of 1
Forum

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!



SQLite - Compact an...
 
Share:
Notifications
Clear all

[Solved] SQLite - Compact and Optimize your database, using VACUUM, in Lazarus Pascal

1 Posts
1 Users
0 Reactions
2,480 Views
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  

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; 
...

   
ReplyQuote
Share: