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

后端 未结 4 946
时光取名叫无心
时光取名叫无心 2020-11-30 08:38

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

4条回答
  •  Happy的楠姐
    2020-11-30 09:14

    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).

提交回复
热议问题