SQLite table disk usage

后端 未结 5 1045
借酒劲吻你
借酒劲吻你 2021-01-30 08:39

How can I find out the disk usage of a single table inside a SQLite database without copying it in a new empty database?

5条回答
  •  后悔当初
    2021-01-30 08:49

    I realize that this answer totally violates the spirit of the question, but it does get you the size without copying the file...

    $ ls -lh db.sqlite
    -rw-r--r-- 1 dude bros 44M Jan 11 18:44 db.sqlite
    $ sqlite3 db.sqlite
    sqlite> drop table my_table;
    sqlite> vacuum;
    sqlite> ^D
    $ ls -lh db.sqlite
    -rw-r--r-- 1 dude bros 23M Jan 11 18:44 db.sqlite
    

提交回复
热议问题