使用多个数据库?


9

在Linux上使用sqlite3,如何使用多个数据库?

我想在数据库1中执行以下操作?

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

如何SELECT为上面的database2 编写查询?


2
您在找ATTACH DATABASE吗?
swasheck

尚未测试,但是我想是的,谢谢!想要发表您的评论作为回复?
stefan.at.wpf 2012年

Answers:


12

(将swasheck的评论重新发布为回复)

sqlite3 database1.db
> ATTACH DATABASE 'database2.db' AS database2;
> INSERT INTO mytable SELECT * FROM database2.mytable;
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.