Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Mandatory One to Many Constraint Problems
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
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
![]() |
![]() |