2

This is probably very basic stuff. I want to create a table if a certain condition is met. Basically I have a db with a version number, and if the version is as expected, a new table is created.

This is pretty straightforward to do, say, in python, but is there a pure SQL way, or then a pure SQLite way, of doing this? Basically I want to know if my update scripts could be free of any other programming langage other than SQL (or SQLite's SQL).

I looked at the CASE clause but it seems I can't use it as a top-level switch statement.

1 Answer 1

2

No, there's no way to do this. SQLite has no flow control statements and the only if condition you can specify on the CREATE TABLE command is IF NOT EXISTS.

You will have to use a scripting language to execute this logic.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.