On Apr 19, 2016, at 1:34 PM, Jarred Ford <jroddrof at hotmail.com> wrote:

> Is it possible to create multiple in-memory databases and be able to access 
> tables with a single query between them?
> For example, select * from db1.dbo.table1 db1 join db2.dbo.table1 db2 on 
> db1.x = db2.x.
> 



Sure.  Like any other database, you?ll need to open the additional databases 
using the ATTACH DATABASE command.  Just open an in-memory database first, then 
run:

ATTACH DATABASE ?:memory:? AS db2

See https://www.sqlite.org/lang_attach.html for more details.  In specific:

The filename for the database to be attached is the value of the expression 
that occurs before the AS keyword. The filename of the database follows the 
same semantics as the filename argument to sqlite3_open() and 
sqlite3_open_v2(); the special name ":memory:" results in an in-memory database 
and an empty string results in a new temporary database.

Note that to run a query across databases (regardless of the type of database), 
the additional databases must be opened with ATTACH.  You cannot run queries 
across databases if you use sqlite3_open*() for anything except the first 
database.

 -j


--  
Jay A. Kreibich < J A Y @ K R E I B I.C H >

"Intelligence is like underwear: it is important that you have it, but showing 
it to the wrong people has the tendency to make them feel uncomfortable." -- 
Angela Johnson



Reply via email to