Sqlite 判斷表是否存在

2021-07-02 07:02:39 字數 300 閱讀 5901

最近的專案有在vc環境下使用sqlite,常常在建立表之前需要知道這個表是否存在。一開始用create table if not exists 這條sql語句,但是會報出錯誤提示「sqlite_misuse」;這種方法行不通,只好自己寫個函式判斷表是否存在。思路是寫乙個查詢語句,接著判斷列的個數,如果列的數目大於0,表示這個表已經建立,等於0,表示不存在這個表。**如下:

bool istableexists(cstring strname)

return ret;

}

c 中如何判斷sqlite表是否存在

在專案中遇到需要判斷sqlite資料庫中某個表是否存在,上網搜尋一些資料後,解決了問題,如下 首先,在每個sqlite資料庫中,都有乙個名為sqlite master的表,它定義了資料庫的模式,它的結構如下 sqlite master type text,專案的型別,如table index vie...

C 中SQLITE3 判斷表是否存在

在網上搜了好多關於 在c 中操作sqlite3 如何判斷表是否存在,但是要麼集中在 select count from sqlite master where type table and name abc 下,要麼是根據 select from abc 下,根據返回值來判斷。今天經試驗,可使用如下...

判斷臨時表是否存在

if object id tempdb.t is not null drop table t if objectproperty object id tempdb.t istable 1 print authors is a table else if objectproperty object i...