Oracle“未找到父密钥”错误

时间:2016-07-03 21:47:24

标签: sql database oracle

继续收到此错误消息,但无法弄清楚导致它的原因......

CREATE TABLE section (
SectionID number (10),
CourseID number(10),
SectionNumber varchar2(10),
Days varchar2(10),
StartTime DATE,
EndTime DATE,
LocationID number (10),
SeatsAvailable number(3),
Status char(1)
);

ALTER TABLE section 
Add CONSTRAINT Student_SectionID_pk 
Primary KEY (SectionID);

ALTER TABLE section
ADD CONSTRAINT section_seatsvaiable_cc
Check (SeatsAvailable < 100);

ALTER TABLE section
Add CONSTRAINT section_CourseID_fk 
FOREIGN KEY (courseid)
references course (courseid);


ALTER TABLE section
Add CONSTRAINT section_LocationID_fk 
FOREIGN KEY (locationid)
references location (locationid);

INSERT INTO SECTION ( sectionid, courseid, SectionNumber, Days, Starttime, endtime, locationid, SeatsAvailable, Status) 
VALUES (1, 99, 'B1-H', 'Tue', '22-MAY-13', '3-AUG-13', 29999, 23, 'A');
  第1行的

错误:

     

ORA-02291:完整性约束(ECOOPER.SECTION_LOCATIONID_FK)   违反 - 未找到父密钥

1 个答案:

答案 0 :(得分:1)

actions: { deleteLocation(model) { Ember.assert("Params must be provided", model); model.save().then(( /* response */ ) => { this.transitionTo('locations'); //locations is my index page. //flash message to inform the user of success. }); }, (error) => { //handle error. // display flash message // rollback any dirty attributes }); } 中不存在ID为29999的位置记录。

所以你的插入没有成功,因为它没有通过所有约束。