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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: columns with primary key constraint

RE: columns with primary key constraint

From: Jamadagni, Rajendra <Rajendra.Jamadagni_at_espn.com>
Date: Mon, 30 Dec 2002 11:58:54 -0800
Message-ID: <F001.00524558.20021230115854@fatcity.com>


SELECT /*+ no_merge(utc) no_merge(ucct.uc) no_merge(ucct.ucc) */

       utc.owner

,utc.table_name
,utc.column_name
,DECODE(ucct.constraint_type, 'P',DECODE(NVL(ucct.cln, ' '), ' ','
','(PK-['||ucct.cn || '] ' || ucct.pos||')'),'') is_pk
,DECODE(ucct.constraint_type, 'R',DECODE(NVL(ucct.cln, ' '), ' ','
','(FK-['||ucct.cn || '] ' || ucct.pos||')'),'') is_fk
FROM DBA_TAB_COLUMNS utc,
(SELECT uc.owner, uc.table_name tn, ucc.constraint_name cn, ucc.column_name cln,

           ucc.position pos, uc.constraint_type     FROM DBA_CONS_COLUMNS ucc,

           DBA_CONSTRAINTS uc
    WHERE ucc.owner = uc.owner
    AND ucc.constraint_name = uc.constraint_name     AND uc.constraint_type IN ('P','R')) ucct WHERE utc.table_name = ucct.tn (+)

AND utc.column_name = ucct.cln (+)
AND utc.owner = ucct.owner
AND utc.OWNer = '<OWNER>'

ORDER BY utc.owner, utc.table_name, ucct.pos /

Just an improvement on Charu's script ... Raj



Rajendra Jamadagni MIS, ESPN Inc.
Rajendra dot Jamadagni at ESPN dot com
Any opinion expressed here is personal and doesn't reflect that of ESPN Inc.

QOTD: Any clod can have facts, but having an opinion is an art!

-----Original Message-----
Sent: Monday, December 30, 2002 2:34 PM
To: Multiple recipients of list ORACLE-L

Charu,

This is exactly what I was looking for.

I will try to modify this now to include an "(FK)" for any column with a foreign key constraint.

Thanks for the extra pair of eyes.

Happy New Year all!

Steve

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Steven Haas
  INET: steven.haas_at_snet.net

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).




-- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Jamadagni, Rajendra INET: Rajendra.Jamadagni_at_espn.com Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).

Received on Mon Dec 30 2002 - 13:58:54 CST

Original text of this message

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