11

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?

Hannah Vernon
  • 70,041
  • 22
  • 171
  • 315
me.at.coding
  • 213
  • 1
  • 2
  • 7

1 Answers1

14

(reposting swasheck's comment as reply)

sqlite3 database1.db
> ATTACH DATABASE 'database2.db' AS database2;
> INSERT INTO mytable SELECT * FROM database2.mytable;
CL.
  • 5,213
  • 1
  • 20
  • 23