rt

解决方案 »

  1.   

    如果涉及到子查询,有区别,如果单表简单操作,无区别.delete tb where ...
    delete from tb where...delete tb where not exists(...) --错误
    delete tb from tb t where not exists(...) --正确.
      

  2.   

    -- 一般习惯用 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行。
      

  3.   


    -- 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行。
      

  4.   

    -- 纠正一下:对于Oracle来说, 1楼说的这种情况应该不存在!