简体   繁体   English

sqlite 通过 C++,打开多个 sqlite 文件

[英]sqlite via c++, opening multiple sqlite files

How do I connect multiple sqlite files into a single sqlite3* handle, in C/C++?如何在 C/C++ 中将多个 sqlite 文件连接到单个 sqlite3* 句柄中? I'm thinking it's possible considering there's a command called ATTACH, but do not know how to do so in C++.我认为考虑到有一个名为 ATTACH 的命令是可能的,但不知道如何在 C++ 中这样做。 Thanks in advance.提前致谢。

Answer (thanks to Robert)答案(感谢罗伯特)

sqlite3_exec(db, "ATTACH 'C:/tmp/tmp.sqlite' as mytmp");

Execute the ATTACH DATABASE SQL command:执行ATTACH DATABASE SQL 命令:

ATTACH path_to_database AS database-name

You can then refer to tables in the attached database as:然后,您可以将附加数据库中的表引用为:

database-name.table-name

http://www.sqlite.org/lang_attach.html http://www.sqlite.org/lang_attach.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM