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 -> Mandatory One to Many Constraint Problems

Mandatory One to Many Constraint Problems

From: Douglas Shook <shook_at_usc.edu>
Date: Mon, 31 May 1999 18:51:19 -0700
Message-ID: <37533C96.4FF1758B@usc.edu>


I created constraints to make a mandatory one to many relationship between a customer table and an invoice table (code is attached) which works fine, but I cannot drop the tables afterwards -- the error message is:

DROP TABLE INV
           *
ERROR at line 1:
ORA-02266: unique/primary keys in table referenced by enabled foreign keys

after I disabled all of the constraints on both tables. I know I am missing something here and would appreciate some help as to why Oracle 7.3 will not let me drop the tables.

thank you,

doug



/* Beginning of code */

create table cust (
 cust_no number(8) constraint cust_pk primary key);

create table inv (
 inv_no number(9) constraint inv_pk primary key,  cust_no number(8) constraint inv_cust_fk references cust

     constraint inv_cust_null not null);

alter table cust add (
 cust_inv number(9) constraint cust_inv_null not null

      constraint cust_inv_unique unique
      constraint cust_inv_fk references inv(inv_no));


create sequence cust_no;
create sequence inv_no;

alter table cust disable constraint cust_inv_fk;

/* inserting first records for customer and invoice */
insert into cust values (cust_no.NextVal, inv_no.NextVal); insert into inv values (inv_no.CurrVal, cust_no.CurrVal);

alter table cust enable constraint cust_inv_fk;

/* inserting subsequent records for existing customer */

insert into inv values (inv_no.NextVal, cust_no.CurrVal);

/* end of code */
Received on Mon May 31 1999 - 20:51:19 CDT

Original text of this message

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