An alternative to CREATING A VIRTUAL TABLE IF IT DOES NOT EXIST

According to the CREATE VIRTUAL TABLE syntax , the IF NOT EXISTS not condition is available .

How do I handle a case where a virtual table already exists without using DROP TABLE IF EXISTS?

I want to use the rtree and fts module.

+3
source share
1 answer

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 return SQLITE_ROW, then your table exists. To verify that it is a virtual table, check the column rootpageat "0".

+5
source

Source: https://habr.com/ru/post/1792399/


All Articles