sql - check table

ssg

Well-Known Member
Licensed User
Longtime User
Hi Erel, or anyone who is familiar with SQL,

Is there a way to know if a table exists in a db?

I am trying to create a new db table when the program is ran for the first time. There is "CreateIfNecessary" option in initializing the db, this will create an empty db.

How can we know if a DB create was triggered? I will need to run some logic to create all necessary tables when the DB gets created for the first time.

Any advice?

Thank your or your time!
 

glook

Member
Licensed User
Longtime User
Erel's solution gives the best control and allows you the most choice in the code.

For simple situations you can also use the syntax: "CREATE TABLE IF NOT EXISTS table_name ......"

This is just ignored if the table is already there.
 
Upvote 0
Top