Oracle Delete Rows Matching On Multiple Values

前端 未结 6 1109
暖寄归人
暖寄归人 2020-12-24 01:58

I want to do something like:

DELETE FROM student WHERE
student.course, student.major IN
(SELECT schedule.course, schedule.major FROM schedule)
6条回答
  •  天涯浪人
    2020-12-24 02:35

    In Oracle, you can do a delete from an in-line view, but it generally needs a foreign key that ensures that a row from the table from which the row is deleted cannot be represented by more than one row in the view.

    create table parent (id number primary key);
    create table child (id number primary key, parent_id number references parent);
    insert into parent values(1);
    insert into child values(2,1);
    delete from (select * from parent p, child c where c.parent_id = p.id);
    

提交回复
热议问题