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: inability to drop table dur to unknown enables FK

Re: inability to drop table dur to unknown enables FK

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 1997/10/05
Message-ID: <3437d94b.2684950@newshost>#1/1

On Sun, 05 Oct 1997 09:34:25 +0200, Yochi Wieman <ordnkv_at_shani.net> wrote:

>Problem : Inability to drop table due to unknown enables
>FK which references the table.
>
>Situation : All known FK referencing the table were disable.
>All data in FK tables was deleted.
>Drop table failed due to 'unique/primary key referenced by enabled
>foreign keys'.
>
>Questions :
>1. In which table can we find all FK referencing a particular
>table ?

*_constraints (user_, all_, dba_

>2. Does DROP TABLE require dropping all the FK or just disabling
>them is enough ?

dropping the foreign keys

>3. If there is no table with FK references, what do you suggest
>as a solution to our problem ? :

I would use the script below before you drop the parent table. If you run it and capture the output, it will generate all of the alter table "child_table" add constraint clauses to rebuild the foreign keys.

What you would do is:

1 - run @cons PARENT_TABLE_NAME and spool the output to a temp file.
2 - drop table PARENT_TABLE_NAME cascade constraints
3 - recreate table PARENT_TABLE_NAME
4 - run temp.sql from 1

restriction: since cons.sql below uses only the user_constraints table, it will not see foreign keys placed from other schemas on your table. this only works if all the foreign keys are owned by the same owner as the table itself.

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Bethesda MD

http://govt.us.oracle.com/ -- downloadable utilities



Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Sun Oct 05 1997 - 00:00:00 CDT

Original text of this message

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