Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Delete clause with sub query

NirvanJan 20 2020 — edited Jan 20 2020

Hi Experts-

Just came across this scenario in Oracle 12c (12.1.0.2.0) where I am trying to delete from emp table by selecting non existing column(emp_name) from dep table as shown below, looks like it is executing successfully.

May I know the reason behind this design or how it will be helpful and what it is called? or is this kind of a bug?

--drop table emp;

CREATE TABLE emp (emp_name VARCHAR2(10));

--table EMP created.

--drop table dep;

CREATE TABLE dep (deptno NUMBER);

--table DEP created.

DELETE FROM emp WHERE emp_name IN (SELECT emp_name FROM dep);

--0 rows deleted.

Thank you,

Pradeep

This post has been answered by Cookiemonster76 on Jan 20 2020
Jump to Answer
Comments
Post Details
Added on Jan 20 2020
6 comments
4,352 views