On Apr 17, 2010, at 2:57 PM, slowpoison wrote:
>
> I want to know whether a TEXT field, when stored, will always take the
> exact amount of space allocated for it in the schema definition. So,
> when I say TEXT(1024), is the field guaranteed to take 1024 bytes on
> disk per record or is there a non-trivial storage scheme at work
> similar to VARCHAR types, which tries to optimize space usage.


The latter.  SQLite stores all strings as if they were in a  
VARCHAR(1000000000).  (That's VARCHAR(one-billion).)  A 5-byte string  
requires 6 bytes of disk (one byte for the string size and 5 for the  
string itself).  A one-billion byte string requires one-billion-and- 
five bytes of disk (5 bytes for the string size and one billion bytes  
to hold the string itself.)

D. Richard Hipp
[email protected]



_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to