Mahesh S wrote:
Hi
I have 3 tables in db2 database. I would like to write a cascading
delete statement and I dont want to use a trigger. Could you please
explain how the statement needs to be?
My table straucture is as follows:
Table1
---ID (PK)
---Field 1
---Field 2
Table 2
---ID (FK) referencing Table1.ID
---Field 3
---Field 4
Table 3
---ID (FK) referencing Table1.ID
---Field 5
---Field 6
What I would like to have is, when I perform a delete on Table 1, I
would like the corresponding related records in table2 and table 3 to
be deleted as well.
DELETE FROM table1
WHERE ...
You don't have to do anything else. Of course, the referential actions
specified for the foreign key constraints have to be defined with the
clause ON DELETE CASCADE.
--
Knut Stolze
DB2 Information Integration Development
IBM Germany