SQLite Forum

Bug: Database schema corruption
Login
The statement:

~~~
   CREATE VIEW IF NOT EXISTS IF AS SELECT null;
~~~

Generates an entry in the sqlite_schema table that contains the
following SQL:

~~~
   CREATE VIEW IF AS SELECT null;
~~~

In other words, the "IF NOT EXISTS" clause gets removed.  That is
unfortunate, because with the IF NOT EXISTS clause, the statement is
successfully parsed and generates a new view named "IF".  But without
the IF NOT EXISTS clause, it is a syntax error.  And this syntax error
gets inserted into the sqlite_schema table, where it causes problems
whenever the schema is parsed again in the future.

You can create similar problems using a statement like:

~~~
   CREATE TABLE IF NOT EXISTS IF(a,b,c);
~~~

There are probably other variations on this same issue.