Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using sqlite3 on Linux, how can one work with multiple databases?

I'd like to do something like the following in database 1?

sqlite3 database1.db
insert into database1.mytable values (select * from database2.mytable) 

How do I write the SELECT query for database2 above?

share|improve this question
are you looking for ATTACH DATABASE? – swasheck Sep 28 '12 at 21:09
Didn't test it yet, but I think so, thanks! Want to post your comment as reply? – Sep 29 '12 at 8:10

(reposting swasheck's comment as reply)

sqlite3 database1.db
> ATTACH DATABASE 'database2.db' AS database2;
> INSERT INTO mytable SELECT * FROM database2.mytable;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.