SELECT
name AS 'Table',
ROUND(
(LENGTH(sql) +
(SELECT SUM(LENGTH(name) + LENGTH(type)) FROM pragma_table_info(sqlite_master.name))
) / 1024.0, 2
) AS 'Schema Size (KB)',
(SELECT COUNT(*) FROM sqlite_master AS sm2 WHERE sm2.name = sqlite_master.name) AS 'Row Count'
FROM
sqlite_master
WHERE
type = 'table'
ORDER BY
name;
重建数据库,删除未使用的空间,并整理碎片
VACUUM;
这个有点适合将sqlite当作临时存储缓存。
sqlite 表大小
计算每个表的占用大小