• Welcome, Guest. Please login.
 
August 19, 2019, 07:15:54 am

News:

Welcome to the SQLitening support forums!


How do I create a table if it does not exist?

Started by Andrew Lindsay, June 29, 2009, 10:32:00 am

Previous topic - Next topic

Andrew Lindsay

I am connecting to a database and I do not know if there is a table present, how do I check if a table is present, and if not, create it?

I tried "If Not Exists FooBar Create FooBar ( Column1 TEXT, Column2 TEXT );"

Any asistance would be appreciated.

Regards

Andrew

Fred Meier


Rolf Brandt

Hello Andrew,

check ExampleB.bas. Here you find the proper syntax:

slExe "Create Table If Not Exists T1 (F1, F2)"

You forgot the "Table" keyword and the order of commands should be different.

Quotetried "If Not Exists FooBar Create FooBar ( Column1 TEXT, Column2 TEXT );"


Correct would be:
"Create Table FooBar If Not Exists ( Column1 TEXT, Column2 TEXT );"


Rolf
I like to cook with wine - sometimes I even add it to the food.
www.rbsoft.eu

Andrew Lindsay

Thanks all kindly.

That has solved it perfectly.

Regards

Andrew