Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: foreign key rule error

Re: foreign key rule error

From: Brian Peasland <oracle_dba_at_peasland.com>
Date: Tue, 22 Oct 2002 15:25:51 GMT
Message-ID: <3DB56DFF.D2CF37C@peasland.com>


> Here's my code, please enlighten me.

The first enlightening statement is to read the Oracle SQL documentation. All of your answers are there. And by reading the docs, you will be able to answer this, and many other questions.

> --------------------------------------------------------------
> create table WORKLOAD
> (
> ENO char(4) not null,
> PNO char(4) not null,
> LOAD number(2,1) not null,
> primary key (ENO, PNO),
> foreign key (ENO) references EMPLOYEE
> on delete cascade
> on update cascade,
> foreign key (PNO) references PROJECTS
> on delete cascade
> on update cascade
> );
> --------------------------------------------------------------

First, there is no "update cascade" natively in Oracle. Second, you should give your constraints a meaningful name. So for the rest, you can use the following:

create table WORKLOAD
(

    ENO char(4) not null,
    PNO char(4) not null,
    LOAD number(2,1) not null,
constraint workload_pk primary key (ENO, PNO), constraint workload__emp_fk foreign key (ENO) references EMPLOYEE

            on delete cascade,
constraint workload__proj_fk foreign key (PNO) references PROJECTS

            on delete cascade
);

HTH,
Brian Received on Tue Oct 22 2002 - 10:25:51 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US