Решение: {1} Используйте ключевое слово CONSTRAINT, {2} присвойте имени ограничение, {3} напишите: ON DELETE CASCADE. Пример (Oracle 12c):
create table mail ( id number primary key ) ;
-- Table MAIL created.
create table disposition ( id number primary key, mailid number ) ;
-- Table DISPOSITION created.
alter table disposition
add constraint disposition_fk
foreign key (mailid) references mail(id) on delete cascade ;
-- Table DISPOSITION altered.
Тестирование
-- table MAIL: insert 5 ids
insert into mail ( id )
select level from dual connect by level <= 5 ;
-- table DISPOSITION: mail ids 1-5 okay, 6 etc not accepted
begin
insert into disposition ( id, mailid ) values ( 101, 1 ) ;
insert into disposition ( id, mailid ) values ( 102, 2 ) ;
insert into disposition ( id, mailid ) values ( 103, 3 ) ;
insert into disposition ( id, mailid ) values ( 104, 4 ) ;
insert into disposition ( id, mailid ) values ( 105, 5 ) ;
end ;
/
-- PL/SQL procedure successfully completed.
insert into disposition ( id, mailid ) values ( 106, 6 ) ;
-- ORA-02291: integrity constraint (...DISPOSITION_FK) violated - parent key not found