Sqlite在删除纪录时不会减小文件大小,只是在文件中将数据块标志为可用。 如果需要强制删除可以运行VACCUM这个命令。具体的可以查看FAQ (12) I deleted a lot of data but the database file did not get anysmaller. Is this a bug?
No. When you delete information from an SQLite database, theunused disk space is added to an internal "free-list" and is reusedthe next time you insert data. The disk space is not lost. Butneither is it returned to the operating system.
If you delete a lot of data and want to shrink the database file,run the VACUUMcommand.VACUUM will reconstructthe database from scratch. This will leave the database with an emptyfree-list and a file that is minimal in size. Note, however, that theVACUUM can take some time to run (around a half second per megabyteon the Linux box where SQLite is developed) and it can use up to twiceas much temporary disk space as the original file while it is running.
As of SQLite version 3.1, an alternative to using the VACUUM commandis auto-vacuum mode, enabled using the auto_vacuum pragma.