SQLite Forum

Does in memory db behave the same as a normal db
Login
> The in-memory or on-disk character of the database is implemented in a way that is not visible to the rest of the library,

Related trivia: unlike on-disk databases, using the db name `":memory:"` multiple times in the same app instance opens up a different in-memory db instance each time. IIRC there's a way to tell sqlite3 to use shared memory, such that all open() calls get the same in-memory db, but i don't recall the specifics.

A brief demo:

```
s2sh2> const sA = new sqlite3(":memory:"), sB = new sqlite3(":memory:")
s2sh2> sA.exec("create table tA(a,b,c)")
s2sh2> sA.selectRows("select * from sqlite_master")
result: array@0x55b0e6dcc220[scope=#1 ref#=0] ==> [{
    "name": "tA",
    "rootpage": 2,
    "sql": "CREATE TABLE tA(a,b,c)",
    "tbl_name": "tA",
    "type": "table"
  }]
s2sh2> sB.selectRows("select * from sqlite_master")
result: array@0x55b0e6dcc280[scope=#1 ref#=0] ==> [] // <== empty array
```

(Edit: typos. See Gunther's response for the shared cache solution.)