On Apr 20, 2016, at 3:22 AM, Dominique Devienne <ddevienne at gmail.com> wrote:

> On Wed, Apr 20, 2016 at 4:40 AM, Jay Kreibich <jay at kreibi.ch> wrote:
>> 
>> 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
>> 
> 
> To attach several memory DBs, it's more like
> 
> ATTACH DATABASE "mem1?mode=memory" as db1;
> ATTACH DATABASE "mem2?mode=memory" as db2;
> etc... ?DD


There is no requirement to use the URI style file type, you can just re-opening 
the special value ?:memory:?.


$ ./sqlite3
SQLite version 3.8.4.2 2014-03-26 18:51:19
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> ATTACH DATABASE ":memory:" AS db2;
sqlite> ATTACH DATABASE ":memory:" AS db3;
sqlite> ATTACH DATABASE ":memory:" AS db4;
sqlite> ATTACH DATABASE ":memory:" AS db5;
sqlite> .databases
seq  name             file                                                      
---  ---------------  ----------------------------------------------------------
0    main                                                                       
2    db2                                                                        
3    db3                                                                        
4    db4                                                                        
5    db5                                     



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