Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check how much space a single row takes in Sqlite

Tags:

android

sqlite

Is there a way to check how much space a single row takes in Sqlite?

I have tried using this way:

I have 4 fields in my table:

id(int)
name(text)
pat(text)
is_default(bool) 

 select *, sum(length(id)+length(name)+length(pat)+length(is_default)) 
    from color;

But it returns character length (for example: 43). How can I determine the row length in bytes?

like image 486
Munish Kapoor Avatar asked Jan 20 '26 20:01

Munish Kapoor


1 Answers

SQLite itself does not give you this information, but the sqlite-analyzer tool does.

If you want to do this from your app, you have to read all the record values and from those deduce how many bytes are used in the on-disk record format.

like image 186
CL. Avatar answered Jan 22 '26 18:01

CL.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!