I’ve got a set of tables that I need to drop in an Sqlite file. They have foreign key constraints. How do I figure out the right order to drop the tables? Or is there a “drop a list of tables” command that will figure that out for me? And what do I search for on the web to get help on this question as adding “order” to any web search related to SQL returns info about the ORDER keyword.
Share
If a table has a foreign key in it, the constraint will prevent you from dropping the table that owns the foreign key. A “foreign key” is simply the primary key of another table, thus it is “foreign” to you. So you need to drop the tables with foreign keys first — then you can drop those other tables. Dropping a table drops its constraints as well.
For brute forcing things you should be able to disable the constraints using: