Discussion Locked

Cascade update and Delete

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I used to read an article on how to produce a cascade update or delete on a foreign key relationship but I don't remember the SQL(T-SQL)syntax.
Thanks in advance

2 replies

by brentlc

(Oracle) you can enable FK's to automatically delete children with the ON DELETE CASCADE option when the FK is created. For updates you would need to write a trigger.

by b_farinha

ALTER TABLE STAFF ADD CONSTRAINT FOREIGN KEY ( room_no ) REFERENCES room( room_no )
ON DELETE CASCADE
ON UPDATE CASCADE

This discussion is closed to new replies.