2

I have to add a constraint to the foreign key + on update cascade, but it shows an error, why?

SQL> alter table affaire_cassation
   2  add constraint key_fk_num_p foreign key(num_aff_a) references 
    affaire_appel(num_aff)
    3  on update cascade;

on update cascade * ERREUR Ó la ligne 3 : ORA-00905: mot-clÚ absent

Dah
  • 92
  • 8

1 Answers1

2

there is no ON UPDATE CASCADE in oracle.

you may want to look at deferrable constraints which defers the foreign key check until commit, update the parent, update the child and then commit.

ALTER TABLE affaire_cassation
ADD CONSTRAINT key_fk_num_p 
FOREIGN KEY(num_aff_a) 
REFERENCES affaire_appel(num_aff)
DEFERRABLE INITIALLY DEFERRED;

You may also look for DEFERRABLE INITIALLY IMMEDIATE where you can defer the constraints on demand when you need it.


use with ALTER SESSION SET CONSTRAINTS = DEFERRED;

Derviş Kayımbaşıoğlu
  • 28,492
  • 4
  • 50
  • 72