Reputation: 31
INSERT INTO TourEvents(TourName,Month,Day,Year,Fee) VALUES ('East ','Jan',16,2016,200)
Error at line 1: ORA-02291: integrity constraint (S9684921.SYS_C003209195) violated - parent key not found
Can someone please explain to me what I might be doing wrong to get this error message To create table i have written below code
CREATE TABLE TourEvents
(
Month varchar(50)
,Day INT
,Year INT
,Fee INT
,TourName varchar(50)
,CONSTRAINT PK_TourEvents PRIMARY KEY (TourName,Month,Day,Year)
,FOREIGN KEY (TourName) REFERENCES TOURS(TourName)
);
I am new to SQL and therefore struggling with constraints a bit. Any help will be greatly appreciated.
Upvotes: 0
Views: 42
Reputation: 21
Create the TOURS
table and insert the record as East in
TourName
column then execute your insert script
Upvotes: 1
Reputation: 1090
Your insert statement is trying to insert a value into column TourName
which doesn't exist in the TOURS
table.
Value East
should be in the TOURS
table as it was used as foreign key.
To better understand foreign key see this
Upvotes: 0