使用一个SQL脚本删除子行和父行 [英] Delete a child and a parent row with one SQL script
本文介绍了使用一个SQL脚本删除子行和父行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不是使用删除子行,而是编写另一个sql语句来删除父行,而是使用一条语句来完成这两个操作.仅供参考:我们使用Oracle数据库.
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
推荐答案
使用级联删除.然后,您只需要删除父"行.
Define your foreign keys with cascading deletes. Then you only need to delete the "parent" row.
这篇关于使用一个SQL脚本删除子行和父行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文