9684921
9684921

Reputation: 31

While creating SQL table and entering data into that table i am receiving error message

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

Answers (2)

Abdul Hameed
Abdul Hameed

Reputation: 21

Create the TOURS table and insert the record as East in

TourName

column then execute your insert script

Upvotes: 1

MD. Nazmul Kibria
MD. Nazmul Kibria

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

Related Questions