I have a SQLite database that contains a number of tables. We are writing a maintenance tool that will remove "stale" data from a table until that table's size is a certain percentage of the total database file or smaller.
I know how to determine the size of the database file -- I do it by executing
PRAGMA PAGE_SIZE;
and
PRAGMA PAGE_COUNT;
in two separate queries and multiplying the two to get the file size in bytes. Yes, I know I can just take the size of the file in bytes, but this is similar to the way I've done it in other databases and I want to stick with it, at least for now.
My problem is I don't know how to get the size of a TABLE. There has to be some way to do this. Can anyone point me in the right direction?
./sqlite3_analyze path_to_db/database.sqlite > dbinfo.sql
will give you detail info on each table's size on disk.VACUUM;
after you finish deleting records)