问题描述:

create table coc (

WS_NO number(10,0) PRIMARY KEY,

last_name varchar2(30),

first_name varchar2(30),

middle_initial varchar2(1),

Email varchar2(2),

contact_no varchar2(11),

date_to_be_submitted date,

applicant_id number(10,0),

company_name VARCHAR2(50),

plant_location VARCHAR2(50),

sample_id number(10,0),

sample_name VARCHAR2(50),

parameters VARCHAR2(50),

CONSTRAINT APPLICANT_FK FOREIGN KEY (applicant_id, company_name, plant_location) REFERENCES APPLICANT (applicant_id, company_name, plant_location),

CONSTRAINT SAMPLE_FK FOREIGN KEY (sample_id, sample_name, parameters) REFERENCES SAMPLE (sample_id, sample_name, parameters));

网友答案:

I think the error message is quite clear. You have columns mentioned in a foreign key constraint, but they are not defined. You need to define them if you want them to reference something else:

create table coc (
    WS_NO number(10,0) PRIMARY KEY,
    last_name varchar2(30),
    first_name varchar2(30),
    middle_initial varchar2(1),
    Email varchar2(2),
    contact_no varchar2(11),
    date_to_be_submitted date,
    applicant_id ??,
    company_name ??,
    plant_location ??,
    sample_id ??,
    sample_name ??,
    CONSTRAINT APPLICANT_FK FOREIGN KEY (applicant_id, company_name, plant_location) REFERENCES APPLICANT (applicant_id, company_name, plant_location),
    CONSTRAINT SAMPLE_FK FOREIGN KEY (sample_id, sample_name, parameters) REFERENCES SAMPLE (sample_id, sample_name, plant_location)
);

Remember: The types need to be the same as in the original table.

网友答案:

The sets of columns (applicant_id, company_name, plant_location) and (sample_id, sample_name, parameters) must be set as unique or primary key in the referenced tables APPLICANT and SAMPLE. Check this by selection from ALL_CONS_COLUMNS filtering by table_name.

相关阅读:
Top