Oracle:ORA-02291:违反了完整性约束(SYSTEM.PATIENT2_FK) - 找不到父密钥

时间:2018-06-01 12:59:45

标签: oracle

在创建此表患者3次后出现此错误 这是病人的SQL:

CREATE TABLE  "PATIENT2" 
   (    "PATIENTID" NUMBER(4,2) NOT NULL ENABLE, 
    "F_NAME" VARCHAR2(15) NOT NULL ENABLE, 
    "L_NAME" VARCHAR2(15) NOT NULL ENABLE, 
    "AGE" NUMBER(2,0) NOT NULL ENABLE, 
    "GENDER" VARCHAR2(1) NOT NULL ENABLE, 
    "BLOODGROUP" VARCHAR2(3) NOT NULL ENABLE, 
    "STREETADDRESS" VARCHAR2(25) NOT NULL ENABLE, 
    "CITY" VARCHAR2(20) NOT NULL ENABLE, 
    "MOBILENUMBER" NUMBER(8,0), 
    "REGISTRATION" DATE, 
    "DOCTORID" NUMBER(2,0) NOT NULL ENABLE, 
     CONSTRAINT "PATIENT2_PK" PRIMARY KEY ("PATIENTID") ENABLE, 
     CONSTRAINT "PATIENT2_FK" FOREIGN KEY ("DOCTORID")
      REFERENCES  "DOCTOR1" ("DOCTORID") ENABLE
   )
/

这里是医生:

CREATE TABLE  "DOCTOR1" 
   (    "DOCTORID" NUMBER(2,0) NOT NULL ENABLE, 
    "F_NAME" VARCHAR2(15) NOT NULL ENABLE, 
    "L_NAME" VARCHAR2(15) NOT NULL ENABLE, 
    "GENDER" VARCHAR2(1) NOT NULL ENABLE, 
    "STREETADDRESS" VARCHAR2(25) NOT NULL ENABLE, 
    "CITY" VARCHAR2(20) NOT NULL ENABLE, 
    "EXPERTISE" VARCHAR2(25) NOT NULL ENABLE, 
     CONSTRAINT "DOCTOR1_PK" PRIMARY KEY ("DOCTORID") ENABLE
   )
/

和我要添加的数据,然后我收到此错误ORA-02291

INSERT INTO PATIENT VALUES(1,'Barry','Allen',24,'M','O+','Hollywood St','Texas','52311300','5-MAY-2017', 7);

任何人都可以帮我告诉我在哪里纠正吗?

0 个答案:

没有答案