I’m working on a project at the moment which is keyed around users, and has a lot of foreign keys linking across various tables. This particular incarnation isn’t in production yet, and I’m writing an import tool to bring in stuff from the old database into the new one. As part of this, I need to delete the data fairly regularly in the “test” system.

So, I go:


And wait… and wait…

Five minutes later (during which time the hard disk light is solidly lit) I realise what it’s up to – there’s about 20 foreign keys resting on the users table, and it’s dropping pretty much the whole database. Ook.