Afriza N Arief Afriza N Arief - 4 years ago 112
C Question

Alternative for CREATE VIRTUAL TABLE IF NOT EXISTS

According to CREATE VIRTUAL TABLE 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.

Answer Source

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'.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download