harshal bhavsar
harshal bhavsar

Reputation: 241

How to check table already created or not in SQlite3

I am creating a table using create table ... (sqlite3_open() and sqlite3_exec()) but I don't know how we know that Database file is already created or not.

Upvotes: 0

Views: 113

Answers (1)

Himanshu
Himanshu

Reputation: 32602

There are two way to check this:

1) You can check directly while creating a table like this:

create table if not exists TableName

2) You can check if table already exists before creating the table like this:

SELECT name FROM sqlite_master WHERE type='table' AND name='table_name';

Upvotes: 1

Related Questions