每次我尝试生成外键或尝试执行on delete cascade时
我有这样的错误:

Error starting at line 9 in command:
CONSTRAINT tp_landlordrole_FK FOREIGN KEY (zillowuseraccountid)
Error report:
Unknown Command

下面是我的代码示例
PROMPT 'Creating Table landlordrole'
CREATE TABLE tp_landlordrole
(
    landlordroleid          NUMBER(20) NOT NULL,
    zillowuseraccountid         NUMBER(20) NOT NULL,
    numberofpropertiesowned     Number(6),
CONSTRAINT tp_landlordrole_PK PRIMARY KEY ( landlordroleid ) ) ;

CONSTRAINT tp_landlordrole_FK FOREIGN KEY (zillowuseraccountid)
    REFERENCES  tp_zillowuseraccount(zillowuseraccountid) ON DELETE CASCADE  ;

PROMPT Creating Index 'tp_landlordrole_I'
CREATE INDEX tp_landlordrole_I ON tp_landlordrole
( zillowuseraccountid );

PROMPT 'Creating Sequence tp_landlordroleid_seq for the tp_landlordrole table'
CREATE SEQUENCE tp_landlordroleid_seq START WITH 0 MINVALUE 0 NOCACHE;

欢迎提出任何建议!啊!

最佳答案

我相信你只需要一个alter table声明:

ALTER TABLE tp_landlordrole
    ADD CONSTRAINT tp_landlordrole_FK
        FOREIGN KEY (zillowuseraccountid) REFERENCES  tp_zillowuseraccount(zillowuseraccountid) ON DELETE CASCADE  ;

但是,可以在表定义中直接定义外键。
CREATE INDEXCREATE SEQUENCE不需要ALTER TABLE

10-08 12:54