View previous topic :: View next topic
|
Author |
Message |
CIS777 Currently Banned New User
Joined: 16 Sep 2005 Posts: 6
|
|
|
|
TABLEA has the following primary key definition:
PRIMARY KEY ( COL1 )
TABLEB has the following foreign key definition:
FOREIGN KEY FK1 ( COLY ) REFERENCES TABLEA ON DELETE CASCADE
What is the result when the SQL UPDATE statement below is executed?
DELETE FROM TABLEA WHERE COL1 = HV1
A. The delete will fail because a primary key value cannot be deleted.
B. The row will be deleted in all cases.
C. The row will be deleted from TABLEA and all rows from TABLEB where COLY = HV1 will also be deleted.
D. The row will be deleted only if no rows exist in TABLEB where COLY = HV1.
E. The row will be deleted only if a separate delete statement is executed before the next COMMIT, deleting all rows from TABLEB where COLY = HV1 if any such rows exist. |
|
Back to top |
|
|
chowdamhemalatha
New User
Joined: 25 Sep 2005 Posts: 2 Location: bangalore
|
|
|
|
Hi,
option C is correct one.
ON DELETE CASCADE means whenever a row in PARENT table (TABLEA) is requested to delete, corresponding rows in all child tables dependent on the parent table (TABLEA) will be deleted. This cascade applies to all lower level child tables that are inturn depent on TABLEB using ON DELETE CASCADE option.
Regards,
Hema. |
|
Back to top |
|
|
|