On 30 Oct 2019, at 1:41pm, Aydin Ozgur Yagmur <ayagmu...@gmail.com> wrote:

> SQLite stores a single database in a single file.
> 
> According to the specific project requirements and due to the performance 
> concerns;
> 
> When working with large databases, is it possible to explicitly tell SQLite 
> not to store the whole DB in a single file and store different tables in 
> different files instead?

SQLite can open with several different files on the same connection using the 
ATTACH DATABASE command:

<https://www.sqlite.org/lang_attach.html>

Open one database in the normal way.  This could be an empty database with no 
tables in.  This database automatically gets the schema name 'main'.  But you 
should supply schema names for attached databases:
ATTACH DATABASE 'second.sqlite' AS suppliers
ATTACH DATABASE 'third.sqlite' AS customers
etc..

There's a limit, somewhere around ten, I think.  Though you can increase it by 
explicitly messing with limits and compilation options.

In your SQL commands you must refer to the schema as part of the table name.  
Otherwise SQLite assumes that the table is part of the 'main' database.  So for 
a table "invoices" you might use

SELECT customer_num, pre_tax_total, post_tax_total
    FROM customers.invoices
    WHERE invoice_date = "20191030"

There are things you cannot split across different database files.  For 
instance, you cannot declare a FOREIGN KEY that refers to a table in a 
different schema.  Because SQLite can't be sure you'll have that schema 
available.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to