What is the best SQL for a SQLite database to effectively do:
If Database Table Exists then
- create table
- insert row
- insert row (i.e. for startup data)
end
What is the best SQL for a SQLite database to effectively do:
If Database Table Exists then
- create table
- insert row
- insert row (i.e. for startup data)
end
To check that your table exists or not, you can use:
SELECT * FROM sqlite_master WHERE name ='myTable' and type='table';
You can let Sqlite itself check this out for you:
CREATE TABLE IF NOT EXISTS <table_name> ...;
Follow link for documentation: https://sqlite.org/lang_createtable.html
Use this code
SELECT name FROM sqlite_master WHERE type='table' AND name='yourTableName';
if returning array count is equal to 1 its means table exist else not exist.