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 wrote:
>
> 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.
ALTER TABLE a DISABLE CONSTRAINT constraint_name
OR
ALTER TABLE a DROP CONSTRAINT constraint_name
If constraint name is unknown you can select it from user_constraints or all_constraints or dba_constraints dictionary view.
SELECT T.table_name AS Table_name , T.constraint_name AS constraint_name , T.constraint_type AS constraint_type -- , R.table_name AS Ref_Table , R.constraint_name AS ref_constraint , R.constraint_type AS ref_constraint_typeFROM user_constraints T
, user_constraints R
WHERE T.constraint_type = 'R' AND T.r_constraint_name = R.constraint_name AND T.r_owner = R.owner
Valery Yourinsky
-- Oracle8 Certified DBA Moscow, RussiaReceived on Wed Apr 11 2001 - 02:05:41 CDT