I create table in SQLite without checking every time whether it exists.
sqlite3_stmt* create_stmt = NULL;
if (sqlite3_prepare_v2(db, "CREATE TABLE mytable (sif INTEGER PRIMARY KEY, name VARCHAR, description VARCHAR);", -1, &create_stmt, NULL) == SQLITE_OK)
{
sqlite3_step(create_stmt);
sqlite3_finalize(create_stmt);
}
If the table doesn’t exist, it will be created; if it exists, nothing happens.
I would like to know if there is some way to get information whether the table is created or just checked?
There’s an equivalent to mysql’s
describe tablein sqlite3 :.schema TABLENAME. See this question for more info about it.So you can issue a
.schema mytablein order to know if it’s been created and what it looks like. In order to be more focused on a single table, you can also use this statement :