且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

sqlite 从具有完全相同架构的两个数据库中附加两个表

更新时间:2023-11-30 19:53:04

您可以使用 ATTACH使另一个数据库文件的内容可在同一连接中访问:

You can use ATTACH to make the contents of another database file accessible in the same connection:

ATTACH "/some/where/db2.sqlite" AS db2;
INSERT INTO main.MyTable SELECT * FROM db2.MyTable;

(主数据库总是被称为main;打开一个新的数据库连接相当于ATTACH "filename" AS main.)

(The main database is always called main; opening a new database connection is the equivalent of ATTACH "filename" AS main.)