sqlite via c++, opening multiple sqlite files

点点圈 提交于 2020-04-11 08:58:06

问题


How do I connect multiple sqlite files into a single sqlite3* handle, in C/C++? I'm thinking it's possible considering there's a command called ATTACH, but do not know how to do so in C++. Thanks in advance.

Answer (thanks to Robert)

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

回答1:


Execute the ATTACH DATABASE SQL command:

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



来源:https://stackoverflow.com/questions/10592292/sqlite-via-c-opening-multiple-sqlite-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!