SQLite Forum

Can not drop a table...
Login
I'm aware of what the situation is, and following the FK dependencies eventually sorted that out. But having lots of references makes that a very manual task because SQLite provides no context in its error message.

My original comment can be enhanced to be more direct:

1. Can the error reporting be made clearer? I.e. point to the table that has the dangling reference, not just to the missing target table.

2. Could the "integrity_check" or "foreign_key_check" pragmas pick up and report on this type of broken schema?

3. \[Comment edited to add this 3rd item\] Perhaps SQLite could even set an internal flag whenever a DDL command is issued during a transaction, and check for an invalid schema just before COMMIT? It would be nice not to put a database into this situation at all.

\[Edited a 2nd time to say\] Sometimes you can't avoid the creation or deletion of tables in the "wrong" order - I regularly make use of circular references, and make schema changes to those tables, so one or the other of CREATE TABLE or DROP TABLE is potentially going to have this issue.