Vote count:
0
I've created below table and put some data in it. But when I tried to check the primary and foreign key constraints, it won't give correct data.
Create Table action(
weekno number(2),
hrsworded number(4,1),
empid number(4),
empname varchar(30), actid number(4), hourlyrate number(5,2), acdescription varchar(30), primary key (empid,actid,weekno), foreign key (empid) references employee, foreign key (actid) references activity );
Try to INSERT these data, and THIS MUST FAIL to verify primary and Foreign key constraints working correctly.
INSERT INTO ACTION(empid,actid,weekno,hrsworded) values(1,171,43,5);
INSERT INTO ACTION(empid,actid,weekno,hrsworded) values(10,163,40,2);
INSERT INTO ACTION(empid,actid,weekno,hrsworded) values(3,155,40,10);
INSERT INTO ACTION(empid,actid,weekno,hrsworded) values(5,188,39,10);
INSERT INTO ACTION(empid,actid,weekno,hrsworded) values(1,163,39,2);
INSERT INTO ACTION(empid,actid,weekno,hrsworded) values(5,151,42,6);
Errors !!
1. OK. 1 rows
Error at line 1: ORA-02291: integrity constraint (S100596334.SYS_C002237232) violated - parent key not found
OK. 1 rows
Error at line 1: ORA-02291: integrity constraint (S100596334.SYS_C002237233) violated - parent key not found
Error at line 1: ORA-00001: unique constraint (S100596334.SYS_C002237231) violated
Error at line 1: ORA-00001: unique constraint (S100596334.SYS_C002237231) violated
PK and FK Test (Must Fail)>?
Aucun commentaire:
Enregistrer un commentaire