Is there a cheap/fast way to merge SQLite db files with different tables?
For example:
a.db
has only tablea
b.db
has only tableb
- ...
I want to merge these into a abcd.db
that contains all tables a
, b
, c
, and d
.
I think what I want is such a magic script:
merge_script a.db b.db c.db d.db -o abcd.db
I have noticed this tip and another tip and the ATTACH trick, which insert all records into "main" database, but can I do this while tables are absent in the "main" database?
UPDATE
I use SQLIte database files as simple storage container.
In most cases, I store each type of data (differed by table name) in a single file, and then merge them into "target" database.
But there are some types of data that should be in the same table name. if use sqlite3 .dump
there would be a conflict in tablename.
Yet the .dump
approach is very simple, I'll just do some workaround and use it.