Sqlite – How to merge many SQLite databases


If I have a large number of SQLite databases, all with the same schema, what is the best way to merge them together in order to perform a query on all databases?

I know it is possible to use ATTACH to do this but it has a limit of 32 and 64 databases depending on the memory system on the machine.

Best Answer

To summarize from the Nabble post in DavidM's answer:

attach 'c:\test\b.db3' as toMerge;           
insert into AuditRecords select * from toMerge.AuditRecords; 
detach toMerge;

Repeat as needed.

Note: added detach toMerge; as per mike's comment.