欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

sqlite 判断表是否存在, 判断某列是否存在 -- c++

程序员文章站 2022-06-10 18:07:36
...

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()) {
	//  有 weight 列
}
else {
	//没有 weight 列
}