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: What columns are in the Primary Key

RE: What columns are in the Primary Key

From: Nicoll, Iain (Calanais) <iain.nicoll_at_calanais.com>
Date: Thu, 10 May 2001 11:22:52 -0700
Message-ID: <F001.002FFC9B.20010510105628@fatcity.com>

Could also try

select * from user_ind_columns where index_name = 'PK_ACCOUNTS'

-----Original Message-----
[mailto:Scott.Shafer_at_dcpds.cpms.osd.mil] Sent: 10 May 2001 19:16
To: Multiple recipients of list ORACLE-L

use user_cons_columns:

SQL> desc user_cons_columns

 Name                            Null?    Type
 ------------------------------- -------- ----
 OWNER                           NOT NULL VARCHAR2(30)
 CONSTRAINT_NAME                 NOT NULL VARCHAR2(30)
 TABLE_NAME                      NOT NULL VARCHAR2(30)
 COLUMN_NAME                     NOT NULL VARCHAR2(30)
 POSITION                                 NUMBER

SQL> select constraint_name , table_name, column_name from user_cons_columns ord
er by constraint_name;

Above query is crude, but effective...

Scott Shafer
San Antonio, TX
210-581-6217

> -----Original Message-----
> From: Helmut Daiminger [SMTP:hdaiminger_at_vivonet.com]
> Sent: Thursday, May 10, 2001 12:23 PM
> To: Multiple recipients of list ORACLE-L
> Subject: What columns are in the Primary Key
>
> Hi!
>
> Is there a data dictionary view that gives me all the columns in a primary
> key of a table?
>
> I can query user_constraints to find out about all constraints on a table:
>
> select * from user_constraints where table_name='TBACCOUNTS'
>
>
> OWNER CONSTRAINT_NAME C TABLE_NAME SEARCH_CONDITION
> ---------- ------------------- - ------------ -------------------------
> VIVOUSER SYS_C003011 C TBACCOUNTS "COMPANYID" IS NOT NULL
> VIVOUSER SYS_C003012 C TBACCOUNTS "STORELOCID" IS NOT NULL
> VIVOUSER SYS_C003013 C TBACCOUNTS "ACCOUNTID" IS NOT NULL
> VIVOUSER PK_ACCOUNTS P TBACCOUNTS
>
> How can I get what columns are in the primary key "PK_ACCOUNTS" ? I have
> more NOT NULL columns in the table than in the PK.
>
> Any idea?
>
> This is 8.1.6 on Win2k.
>
> Thanks,
> Helmut
>
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author: Helmut Daiminger
> INET: hdaiminger_at_vivonet.com
>
> Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> San Diego, California -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> 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.com
-- 
Author: 
  INET: Scott.Shafer_at_dcpds.cpms.osd.mil

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
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.com
-- 
Author: Nicoll, Iain (Calanais)
  INET: iain.nicoll_at_calanais.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
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 Thu May 10 2001 - 13:22:52 CDT

Original text of this message

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