delete from msgmessag where exists (select 1 from msgmessag where contentid='9') 在oracle中执行这条语句后的结果不是应该:将msgmessag中contentid='9'的记录删除掉么?怎么会把msgmessag 这个表中所有的记录都给删掉
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/19 02:09:52
![delete from msgmessag where exists (select 1 from msgmessag where contentid='9') 在oracle中执行这条语句后的结果不是应该:将msgmessag中contentid='9'的记录删除掉么?怎么会把msgmessag 这个表中所有的记录都给删掉](/uploads/image/z/9620067-3-7.jpg?t=delete+from+msgmessag+where+exists+%28select+1+from+msgmessag+where+contentid%3D%279%27%29+%E5%9C%A8oracle%E4%B8%AD%E6%89%A7%E8%A1%8C%E8%BF%99%E6%9D%A1%E8%AF%AD%E5%8F%A5%E5%90%8E%E7%9A%84%E7%BB%93%E6%9E%9C%E4%B8%8D%E6%98%AF%E5%BA%94%E8%AF%A5%EF%BC%9A%E5%B0%86msgmessag%E4%B8%ADcontentid%3D%279%27%E7%9A%84%E8%AE%B0%E5%BD%95%E5%88%A0%E9%99%A4%E6%8E%89%E4%B9%88%3F%E6%80%8E%E4%B9%88%E4%BC%9A%E6%8A%8Amsgmessag+%E8%BF%99%E4%B8%AA%E8%A1%A8%E4%B8%AD%E6%89%80%E6%9C%89%E7%9A%84%E8%AE%B0%E5%BD%95%E9%83%BD%E7%BB%99%E5%88%A0%E6%8E%89)
delete from msgmessag where exists (select 1 from msgmessag where contentid='9') 在oracle中执行这条语句后的结果不是应该:将msgmessag中contentid='9'的记录删除掉么?怎么会把msgmessag 这个表中所有的记录都给删掉
delete from msgmessag where exists (select 1 from msgmessag where contentid='9')
在oracle中执行这条语句后的结果不是应该:将msgmessag中contentid='9'的记录删除掉么?怎么会把msgmessag 这个表中所有的记录都给删掉呢?
delete from msgmessag where exists (select 1 from msgmessag where contentid='9') 在oracle中执行这条语句后的结果不是应该:将msgmessag中contentid='9'的记录删除掉么?怎么会把msgmessag 这个表中所有的记录都给删掉
是会删除所有记录的,因为子查询这条记录是存在的.
你的查询可解释为删除 如果子查询中(msgmessag表)存在等于9的记录,就删除主表msgmessag.
应该与删除表建立关联:
delete from msgmessag where exists (select 1 from msgmessag A where contentid='9' AND A.CONTENTID=MSGMESSAG.CONTENTID)
该查询可解释为:删除 如果msgmessag(主查询)CONTENTID字段与子查询相同就删除该记录.(子查询中的CONTENTID字段等于9并且与主查询相同).
效果等同于delete from msgmessag where contentid='9