Vihaan Verma
Vihaan Verma

Reputation: 13143

Sqlite giving column more size than needed

I have some data which I will be putting in the database. Say I make a field like "coupondetail text(10000)" which will store the coupon detail, now consider that not all coupondetail will be 10,000 chars long. I m curious to know how much space will the column take in the database when the coupondetail text is lesser than 10,000 say 1000 chars?

Upvotes: 1

Views: 31

Answers (1)

laalto
laalto

Reputation: 152827

sqlite does not care much how you declare your column types and ignores any maximum length specified. The declared type is just a hint; any non-INTEGER PRIMARY KEY column can contain any type.

The size taken up in the database file depends on the values you put in. In the record format, strings are stored as length followed by string data. No empty space is necessarily left there.

Upvotes: 3

Related Questions