SQLite Attach Database
Working with multiple databases
Attach Database
ATTACH DATABASE 'other.db' AS other; # attach database
.databases # list attached databases
Query Attached DB
SELECT * FROM other.users; # query attached database
INSERT INTO other.logs SELECT * FROM main.logs; # copy data
Join Across Databases
SELECT u.name, o.total
FROM main.users u
JOIN other.orders o ON u.id = o.user_id; # join tables from different DBs
Detach Database
DETACH DATABASE other; # detach database
In-Memory Database
ATTACH DATABASE '' AS temp; # attach in-memory database
ATTACH DATABASE 'file::memory:?cache=shared' AS mem; # shared memory DB