Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite VARCHAR default size

Tags:

sqlite

In SQLite, when I say:

CREATE TABLE my_table  (     my_column VARCHAR  ); 

without specifying the size of VARCHAR, what is the default size that is used?

I can't seem to find it at sqlite.org or figure out from my database file.

I know that SQLite doesn't enforce size when trying to stuff varchar(500) into varchar(30), but are there tradeoffs in initial size specification and what are best practices?

like image 373
Turar Avatar asked Jan 24 '11 23:01

Turar


People also ask

How big is too big for SQLite?

An unlikely requirement for an engine popular on Android and iOS. SQLite, which claims to be "used more than all other database engines combined", has been updated to version 3.33. 0 with the maximum size increased to 281TB, around twice the previous capacity of 140TB.

How can I get table size in SQLite?

sqlite > dbinfo. sql will give you detail info on each table's size on disk.

What is difference between text and VARCHAR in SQLite?

More Details. TEXT has a fixed max size of 2¹⁶-1 = 65535 characters. VARCHAR has a variable max size M up to M = 2¹⁶-1 . So you cannot choose the size of TEXT but you can for a VARCHAR .

How many entries can SQLite handle?

Maximum Number Of Pages In A Database FileThe largest possible setting for SQLITE_MAX_PAGE_COUNT is 4294967294. When used with the maximum page size of 65536, this gives a maximum SQLite database size of about 281 terabytes. The max_page_count PRAGMA can be used to raise or lower this limit at run-time.


2 Answers

It doesn't matter.

SQLite does not use sizes when declaring the VARCHAR type. In fact, it almost doesn't use the type either.

You can store TEXT in an INT column in SQLite. And SQLite will never truncate a TEXT column.

like image 95
Larry Lustig Avatar answered Oct 25 '22 19:10

Larry Lustig


From what I can gather, VARCHAR is the same as TEXT

http://www.sqlite.org/datatype3.html

Also see http://www.sqlite.org/different.html#flex

like image 43
hlindset Avatar answered Oct 25 '22 19:10

hlindset