December 3rd, 2003, 01:20 AM
Problems with "Delete" statement in SQL
I have the table: R1(A, B, C)
Primary Key (A, B)
Foreign Key (A)
I'm trying to delete a row using the query:
delete from R1 where A = 123;
However, Oracle freezes on me. Please help. Thanks.
December 4th, 2003, 08:00 AM
Primary and foreign keys are defined the parent/child relationship, you cannot delete a record from parent table until it has record in child table. I think your parent table R1 has any child record that's why oracle does not allow to delete this parent record because oracle respects the parent/child relationship. For your future reference you should define keyword ON DELETE CASCADE with your primary key, this key implicitly delete the child records when you try to delete parent record. But this time delete the associative child record of this primary key from the child table then delete it from parent table.