Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: How can I get a list of referenced keys?
A copy of this was sent to haven_at_havenskys.com
(if that email address didn't require changing)
On Fri, 12 Jun 1998 20:37:51 GMT, you wrote:
>You can find the information in the SYS.DBA_CONSTRAINTS view.
>- haven - wrote in message <35818C6E.FDF1F7F7_at_havenskys.com>...
>>I need to get drop this table. How can I get a list of referenced keys?
If you just need to drop the table,
SQL> drop table ABC cascade constraints;
will drop it. If you want to drop it, rebuild it, and have the foreign keys put back on, then the following script will help perhaps. You run it on the table you want to drop and it will generate all of the ALTER commands for the children tables to put the foreign keys back on. So, it will list all of the names of the foreign keys referencing the table...
column fkey format a80 word_wrapped
select
'alter table "' || child_tname || '"' || chr(10) || 'add constraint "' || child_cons_name || '"' || chr(10) || 'foreign key ( ' || child_columns || ' ) ' || chr(10) || 'references "' || parent_tname || '" ( ' || parent_columns || ');' fkeyfrom
b.r_constraint_name parent_cons_name, max(decode(position, 1, '"'||column_name||'"',NULL)) || max(decode(position, 2,', '||'"'||column_name||'"',NULL)) || max(decode(position, 3,', '||'"'||column_name||'"',NULL)) || max(decode(position, 4,', '||'"'||column_name||'"',NULL)) || max(decode(position, 5,', '||'"'||column_name||'"',NULL)) || max(decode(position, 6,', '||'"'||column_name||'"',NULL)) || max(decode(position, 7,', '||'"'||column_name||'"',NULL)) || max(decode(position, 8,', '||'"'||column_name||'"',NULL)) || max(decode(position, 9,', '||'"'||column_name||'"',NULL)) || max(decode(position,10,', '||'"'||column_name||'"',NULL)) || max(decode(position,11,', '||'"'||column_name||'"',NULL)) || max(decode(position,12,', '||'"'||column_name||'"',NULL)) || max(decode(position,13,', '||'"'||column_name||'"',NULL)) || max(decode(position,14,', '||'"'||column_name||'"',NULL)) || max(decode(position,15,', '||'"'||column_name||'"',NULL)) || max(decode(position,16,', '||'"'||column_name||'"',NULL)) child_columns
max(decode(position, 1, '"'||column_name||'"',NULL)) || max(decode(position, 2,', '||'"'||column_name||'"',NULL)) || max(decode(position, 3,', '||'"'||column_name||'"',NULL)) || max(decode(position, 4,', '||'"'||column_name||'"',NULL)) || max(decode(position, 5,', '||'"'||column_name||'"',NULL)) || max(decode(position, 6,', '||'"'||column_name||'"',NULL)) || max(decode(position, 7,', '||'"'||column_name||'"',NULL)) || max(decode(position, 8,', '||'"'||column_name||'"',NULL)) || max(decode(position, 9,', '||'"'||column_name||'"',NULL)) || max(decode(position,10,', '||'"'||column_name||'"',NULL)) || max(decode(position,11,', '||'"'||column_name||'"',NULL)) || max(decode(position,12,', '||'"'||column_name||'"',NULL)) || max(decode(position,13,', '||'"'||column_name||'"',NULL)) || max(decode(position,14,', '||'"'||column_name||'"',NULL)) || max(decode(position,15,', '||'"'||column_name||'"',NULL)) || max(decode(position,16,', '||'"'||column_name||'"',NULL)) parent_columns
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA
http://govt.us.oracle.com/ -- downloadable utilities
Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Fri Jun 12 1998 - 18:44:21 CDT