SQLite官网:http://www.sqlite.org
cppsqlite下载地址:https://github.com/lmmir/CppSQLite3
1. sqlite 判断表是否存在
//第三方库 cppsqlite3
CppSQLite3DB db;
db.open("...");
if ( !db.tableExists("表名") ) //判断表存在
{
return 0;
}
2. sqlite 判断某列是否存在
CppSQLite3DB db;
db.open("...");
// sqlite_master 为sqlite隐藏系统表
CppSQLite3Query query = db.execQuery("select * from sqlite_master where name='表名' and sql like '%列名%';");
if (!query.eof()) {
// 有 "列名" 列
}
else {
//没有 "列名" 列
}
本文介绍如何使用cppsqlite3库在SQLite中检查表和列的存在性。通过具体代码示例,展示如何判断指定的表是否存在于数据库中,以及如何确认表中是否存在特定的列。

7470

被折叠的 条评论
为什么被折叠?



