SQLite Forum

Queries across databases
Login
The SQL for it is simply:

```
ATTACH DATABASE 'c:/sqlite/db/contacts.db' AS contacts;

and in program terms:
sqlite3_exec(pdb, "ATTACH DATABASE 'c:/sqlite/db/contacts.db' AS contacts;" ... );
```
Which should all already work according to your given example, but note that:

- attaching has to be allowed by your version of SQLite (or C# wrapper for it),
- there are limits to how many DBs can be attached,
- you need read/write privileges to the folder of the file you are attaching,
- and to the DB file itself. (Depending on the Journal mode and intended use.)


To get rid of it again you can do:

```
DETACH DATABASE contacts;
```