Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there a limit to the size of a SQLite database?

Tags:

sqlite

I have read their limits FAQ, they talk about many limits except limit of the whole database.

like image 461
user310291 Avatar asked May 06 '10 01:05

user310291


People also ask

How large can a SQLite database be?

SQLite database files have a maximum size of about 140 TB. On a phone, the size of the storage (a few GB) will limit your database file size, while the memory size will limit how much data you can retrieve from a query. Furthermore, Android cursors have a limit of 1 MB for the results.

How many records can SQLite handle?

A SQLite database can have maximum 2147483646 pages. Hence the maximum number of tables in a schema cannot reach more than 2147483646. The maximum number of rows in a table is 264. The maximum number of columns is 32767 in a table.

What is the maximum size of SQLite database in Android?

Maximum Database Size 140 tb but it will depends on your device disk size.

What is the maximum size of SQLite varchar?

(9) What is the maximum size of a VARCHAR in SQLite? SQLite does not enforce the length of a VARCHAR. You can declare a VARCHAR(10) and SQLite will be happy to store a 500-million character string there. And it will keep all 500-million characters intact.


1 Answers

This is fairly easy to deduce from the implementation limits page:

An SQLite database file is organized as pages. The size of each page is a power of 2 between 512 and SQLITE_MAX_PAGE_SIZE. The default value for SQLITE_MAX_PAGE_SIZE is 32768.

...

The SQLITE_MAX_PAGE_COUNT parameter, which is normally set to 1073741823, is the maximum number of pages allowed in a single database file. An attempt to insert new data that would cause the database file to grow larger than this will return SQLITE_FULL.

So we have 32768 * 1073741823, which is 35,184,372,056,064 (35 trillion bytes)!

You can modify SQLITE_MAX_PAGE_COUNT or SQLITE_MAX_PAGE_SIZE in the source, but this of course will require a custom build of SQLite for your application. As far as I'm aware, there's no way to set a limit programmatically other than at compile time (but I'd be happy to be proven wrong).

like image 154
Mark Rushakoff Avatar answered Sep 19 '22 19:09

Mark Rushakoff