I am using the following code to drop my database tables.
"DROP TABLE IF EXISTS TableName;"
The tables are deleted but I have noticed that the data is still inside the file. That is, after executing this command I would expect my file to have zero bytes, yet the file does not lose a single byte of its size.
Is there a way to delete the table and also all the data in that table?
The deletion of a table, as you have already realized, is simply a logical deletion, the structure and the data are still physically in the database, the used space is recovered as needed. To delete and reorganize the physical file of a database
sqlite
you have the clauseVACCUM
. Executing this command reorganizes the database space to the bare minimum, reducing space and data fragmentation.