Friday, March 9, 2012

Problems with Delete statement

Hi,
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.A foreign key must reference the entire primary key or unique set of columns, thus foreign key (A) in your below table must indicate that (A) refers to a column in another table that i'll call R.

R(A) primary key (A)
R1 (A, B, C) primary key (A, B)
foreign key (A) references R(A)

By default deleting the value of A will have no effect, as A in this case is a child. An error would arise if the primary key of R1 was reference as a foreign key elsewhere as A is part of the parent key.

However given the above simple relations,

delete from R1 where a = x produces no error.

Thus, the problem is not constraint related with default constraint options.

No comments:

Post a Comment