delete 与 delete from 有区别吗

crazyleeyang 2011-09-28 10:42:21
rt
...全文
802 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
crazyleeyang 2011-09-28
  • 打赏
  • 举报
回复
好的,多谢3楼,请接分
dawugui 2011-09-28
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 luoyoumou 的回复:]
-- 纠正一下:对于Oracle来说, 1楼说的这种情况应该不存在!
[/Quote]原来如此.
luoyoumou 2011-09-28
  • 打赏
  • 举报
回复
-- 纠正一下:对于Oracle来说, 1楼说的这种情况应该不存在!
luoyoumou 2011-09-28
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 dawugui 的回复:]

如果涉及到子查询,有区别,如果单表简单操作,无区别.

delete tb where ...
delete from tb where...

delete tb where not exists(...) --错误
delete tb from tb t where not exists(...) --正确.
[/Quote]

-- 1楼说的这种情况应该不存在:

scott@TBWORA> delete emp where not exists (select 1 from dept where dept.dname='LUOYOUMOU' and dept.deptno=emp.deptno);

已删除5行。

scott@TBWORA> rollback;

回退已完成。

scott@TBWORA> delete from emp where not exists (select 1 from dept where dept.dname='LUOYOUMOU' and dept.deptno=emp.deptno);

已删除5行。

scott@TBWORA> rollback;

回退已完成。

scott@TBWORA> delete emp where not exists (select 1 from dept where dept.dname='RESEARCH' and dept.deptno=emp.deptno);

已删除0行。

scott@TBWORA> delete from emp where not exists (select 1 from dept where dept.dname='RESEARCH' and dept.deptno=emp.deptno);

已删除0行。

luoyoumou 2011-09-28
  • 打赏
  • 举报
回复
-- 一般习惯用 delete from ,这样写更让人容易理解!

-- 当然:没有区别!
sys@TBWORA> conn scott/bee56915
已连接。
scott@TBWORA> delete emp;

已删除5行。

scott@TBWORA> delete from emp;

已删除0行。

scott@TBWORA> delete emp2;

已删除0行。

scott@TBWORA> delete from emp2;

已删除0行。

scott@TBWORA> delete emp2 where deptno=30;

已删除0行。
dawugui 2011-09-28
  • 打赏
  • 举报
回复
如果涉及到子查询,有区别,如果单表简单操作,无区别.

delete tb where ...
delete from tb where...

delete tb where not exists(...) --错误
delete tb from tb t where not exists(...) --正确.

17,090

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧