SQLite Forum

DROP VIEW IF EXISTS failure
Login
The documentation could be more clear about this odd case. Whether the additional verbiage would dilute the rest with less detriment that the rare confusion you have suffered is unclear.  I suspect the additional "clarity" would consume brain cycles that would be put to better use elsewhere.

Your 2nd point puzzles me.  I have used "drop X if exists SomeName" a lot in development, always to ensure recreation of an X entity that might already be present, **as an X entity**.  I hardly ever, perhaps never, have cause to convert tables to views or vice versa, and have never been faced with your difficulty. (This is why I do not see documentation clarity on this as being more useful than pedantic.)

I assume you want a view to be dropped because you are creating another one with the same name. But I cannot square such a desire with uncertainty as to whether a table of that name already exists.  If you do not intend to recreate a view, and just intend to remove some grunge from a database, that is very much a one-off kind of problem, unworthy of lament such as "complicates a lot!". These considerations leave me wondering how your conundrum arose, and to question whether it is an ongoing, real difficulty or simply an unpleasant surprise coupled with insistence that your expectation was "correct". (I sympathize with that view, even if I don't agree with it.)

Can you describe some scenario, **likely to be repeated**, where this in fact creates more work than the following pseudo-code?

```
drop view if exists SomeViewOrTable;
if failed {
  drop table SomeViewOrTable;
}
if failed {
  yap
} else {
  be happy
}
```

BTW, I understood your initial complaint. What I did not understand is how you could not already know whether you had a table or a view.