Delete a child and a parent row with one SQL script

WowBow picture WowBow · Mar 9, 2012 · Viewed 85.8k times · Source

Instead of deleting the child row and then writing another sql statement to delete the parent row I wanted to use one statement which will do both. FYI: we use Oracle database.

Update: I dont have a privilege to do DELETE ON CASCADE

Answer

Albin Sunnanbo picture Albin Sunnanbo · Mar 9, 2012

Define your foreign keys with cascading deletes. Then you only need to delete the "parent" row.