Alternative for CREATE VIRTUAL TABLE IF NOT EXISTS
According to CREATE VIRTUAL TA开发者_运维百科BLE syntax, IF NOT EXISTS clause is not available.
How should I handle the case when the virtual table already exists without using DROP TABLE IF EXISTS?
I want to use rtree and fts module.
You can use
select DISTINCT tbl_name from sqlite_master where tbl_name = ?
Then bind the virtual table name to your statement and call sqlite3_step(). If you get SQLITE_ROW back, then your table exists. To be certain that it is a virtual table, check the rootpage
column for '0'.
This is now supported since sqlite 3.7.11.
changelog
精彩评论