Delete a child and a parent row with one SQL script

前端 未结 7 664
执念已碎
执念已碎 2021-01-04 00:30

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 databa

7条回答
  •  青春惊慌失措
    2021-01-04 00:48

    Another (boring way, we have this in a database which, for unknown reason, don't use foreign keys as constraints - yes yes) to do this would be to create a trigger after (or before) delete.

    You'll have to write another delete query, but just in the trigger.

    But if you can't put delete cascade, I'm not sure you can add triggers...

提交回复
热议问题