oracle 组合主键的外键

2w2cym1i  于 2022-11-03  发布在  Oracle
关注(0)|答案(1)|浏览(164)

我需要创建一个复合主键的前景,但它不能运行。我认为问题是当我引用前景键表时

CREATE TABLE CLEPRIMAIRE
(
    aa INT,
    bb INT,

    CONSTRAINT PK_AA_BB PRIMARY KEY (aa,bb)
);

CREATE TABLE CLEPETRANGERE
(
    ee INT,
    ff INT,

    CONSTRAINT PK_EE PRIMARY KEY (ee),
    CONSTRAINT FK_FF FOREIGN KEY (ff) REFERENCES CLEPRIMAIRE(aa,bb)
);

我试着给它编码,但它不工作

Rapport d'erreur -
ORA-02256: le nombre de colonnes de référence doit correspondre au nombre de colonnes référencées
02256. 00000 -  "number of referencing columns must match referenced columns"

* Cause:    The number of columns in the foreign-key referencing list is not

           equal to the number of columns in the referenced list.

* Action:   Make sure that the referencing columns match the referenced

           columns.
cyvaqqii

cyvaqqii1#

CREATE TABLE CLEPETRANGERE
(
    ee INT,
    ff INT,
    gg INT,

    CONSTRAINT PK_EE PRIMARY KEY (ee),
    CONSTRAINT FK_FF FOREIGN KEY (ff, gg) REFERENCES CLEPRIMAIRE(aa,bb)
);

这是你需要的吗?

相关问题