Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to drop a foreign key
"David YEUNG" <dyeung_at_ust.hk> a ecrit dans le message news: 3AD3D84A.27B789E1_at_ust.hk...
> I have a table A which contains a foreign key reference to
> table B's primary key, e.g.:
>
> create table A (
> ...
> fid varchar2(16) not null,
> ...
> foreign key (fid) references B(pid) on delete cascade
> )
>
> where pid is the primary key of the table B.
>
> Can someone tell me how to drop (or disable) the foreign key in table A.
>
> Thanks
>
> david
First, it is a goog thing to always name your constraint:
create table A (
...
fid varchar2(16) not null,
...
constraint A_fk foreign key (fid) references B(pid) on delete cascade
)
it is easier to drop them with alter table:
alter table A drop constraint A_fk;
Now, you have to find the name generated by the system for your
constraint:
select constraint_name, r_constraint_name
from user_constraints
where table_name='A' and constraint_type='R';
r_constraint_name is the unique/primary key constraint on your B table.
constraint_name is the actual name of your constraint.
Then you can drop the constraint with alter table.
-- Have a nice day MichelReceived on Wed Apr 11 2001 - 02:33:33 CDT