Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: SQL query for foreign keys?

Re: SQL query for foreign keys?

From: Stan Brown <stanb_at_panix.com>
Date: 24 Jul 2001 15:15:18 -0400
Message-ID: <9jkhg6$58o$1@panix2.panix.com>

In <995999735.18431.0.pluto.d4ee154e_at_news.demon.nl> "Sybrand Bakker" <postbus_at_sybrandb.demon.nl> writes:

>"Kay Kanekowski" <kkanekowski_at_mindcommerce.de> wrote in message
>news:9jj4n4$gi9$1_at_fermi.tro.net...
>> Hi ,
>>
>> try this
>>
>> SELECT *
>> FROM user_cons_columns
>> WHERE constraint_name IN
>> ( SELECT DISTINCT dt.constraint_name
>> FROM user_constraints m, -- table with PK
>> user_constraints dt -- table with FK
>> WHERE m.table_name = UPPER( '&1' )
>> AND m.constraint_name = dt.r_constraint_name );
>>
>> hth
>> Kay
>>
>> Mail: kkanekowski_at_mindcommerce.de
>>
>>
>>
 

>Just one small tip for you: the result of a subquery is a set.
>Sets are unique by design. Your distinct is redundant.
>Oracle however is stupid enough to perform 2 distincts on the results on the
>subquery.

Thanks for the tip.

Do you have any of your usual helpful sugestions regarding how to corectly format the query I originally asked about? Received on Tue Jul 24 2001 - 14:15:18 CDT

Original text of this message

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