Right now I have this statement
DELETE FROM sqlite_sequence where name = 'table_name';
which works fine in most cases, but now I have a case where the sqlite_sequence
table is not being created and so I get back
no such table: sqlite_sequence
I need a statement that only does the delete if the table exists. I've found this statement to tell me if the table exists or not
SELECT name FROM sqlite_master WHERE type='table';
But so far I've been unable to successfully pair it with the delete satement
The table existence check should include the name, of course
SELECT count(*) FROM sqlite_master WHERE type='table' AND name='table_name';
But you'll have to do it from the calling application in separate statements, i.e. run the above, and based on the count (naturally 1=true, 0=false) as boolean value, you can proceed to run the DELETE statement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With