Ib311 Ib311 - 7 months ago 26
SQL Question

ORA-02256: number of referencing columns must match referenced columns

ORA-02256: number of referencing columns must match referenced columns

Error Im getting.

Allocation is weak entity not sure how to fix any help would be nice :D

Answer

You need to Mention the referring table's column as well.

CREATE TABLE ALLOCATION (
  MgrId number (3),
  ProdId number(4),
  PRIMARY KEY (MgrId, ProdId),
  FOREIGN KEY (ProdId) REFERENCES PRODUCT(ProdId),
  FOREIGN KEY (MgrId) REFERENCES MANAGER(MgrId)
);

And always refer the parent table. Though not it is mandatory. It is just a standard to be followed.

CREATE TABLE QUALITYCHECK (
  WeekNo number (1),
  Score number (1),
  MgrId number (3) NOT NULL,
  ProdId number(4) NOT NULL,
  PRIMARY KEY (WeekNo, MgrId, ProdId),
  FOREIGN KEY (MgrId) REFERENCES MANAGER(MgrId),
  FOREIGN KEY (ProdId) REFERENCES PRODUCT(ProdId)
);
Comments