无法建立一对一的关系

时间:2013-05-11 06:40:08

标签: mysql db2 one-to-one cardinality

我无法在多个数据库(mysql,db2)中创建一对一的关系。 这是我的声明:

--<ScriptOptions statementTerminator=";"/>

CREATE SCHEMA "mydb";

CREATE TABLE "mydb"."first" (
        "id" BIGINT NOT NULL
    )
    DATA CAPTURE NONE 
    COMPRESS NO;

CREATE TABLE "mydb"."second" (
        "id" BIGINT NOT NULL
    )
    DATA CAPTURE NONE 
    COMPRESS NO;

ALTER TABLE "mydb"."first" ADD CONSTRAINT "prima_PK" PRIMARY KEY
    ("id");

ALTER TABLE "mydb"."second" ADD CONSTRAINT "seconda_PK" PRIMARY KEY
    ("id");

ALTER TABLE "mydb"."first" ADD CONSTRAINT "first_second_FK" FOREIGN KEY
    ("id")
    REFERENCES "mydb"."second"
    ("id")
    ON DELETE CASCADE;

此声明在mysql和db2上产生一对多关系。有人可以帮我解决这个话题吗?

0 个答案:

没有答案