Click to See Complete Forum and Search --> : delete all foreignkey-ed rows


vin
August 29th, 2000, 02:48 AM
Hi,

I want to delete a record but It has many foreign key-related records in other tables.
Was there a way in SQL that can delete all
records that are related, with one command.

Thanks.

Lothar Haensler
August 29th, 2000, 04:46 AM
if your database system supports cascading deletes you can use the DELETE FROM tablename statement to delete a record and all its dependent records.
This works only if you have defined "ON DELETE CASCADE" in your definitions for your relationships.