On 10/10/08, ferrety ferrety <[EMAIL PROTECTED]> wrote: > Hi, > > I'm new to SQLite and to list !!! So ... > > I've "N" sqlite DBs all produced with the same version of SQLite3 and > all having the same DB schema (only 1 table). > I'd like to merge them all in one single DB. The merge process needs > to be done as fast as possible. > > Let me give you how the DBs looks like in a real example. > Each DB contains a uniq table called URL : > > CREATE TABLE if not exists URL (name VARCHAR PRIMARY KEY, nbr INTEGER); > > $ sqlite3 /tmp/links1.db : > sqlite> select * from URL; > www.foo.com|17 > www.bar.com|100 > www.lost.com|5 > > $ sqlite3 /tmp/links2.db : > sqlite> select * from URL; > www.lost.com|22 > www.bar.com|9 > www.dharma.com|1 > > The objective is to merge these 2 DBs in the first one > "/tmp/links1.db" to get this: > $ sqlite3 /tmp/links1.db : > sqlite> select * from URL; > www.foo.com|17 > www.lost.com|27 > www.bar.com|109 > www.dharma.com|1 > > I'll generalize the solution to "N" DBs after that. > > Any advice or code will be very welcome?
$ sqlite3 /tmp/links1.db sqlite> ATTACH '/tmp/link2.db' AS foo; sqlite> INSERT INTO URL SELECT * FROM foo; sqlite> DETACH foo; sqlite> ATTACH '/tmp/link3.db' AS foo; sqlite> INSERT INTO URL SELECT * FROM foo; lather, rinse, repeat N times. Script using your favorite language. There are many more ways this can be done. > > Regards > Ferret > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users