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: newbie-desc command

Re: newbie-desc command

From: Rauf Sarwar <rs_arwar_at_hotmail.com>
Date: 17 May 2003 17:35:53 -0700
Message-ID: <92eeeff0.0305171635.5bbaf7b2@posting.google.com>


Me <me_at_privacy.net> wrote in message news:<b1vccvgbffv5ro9n7qso72n8ilrhjfjdrm_at_4ax.com>...
> In Oracle SQL* Plus desc command give the information of a table but
> how does one know which is the primary key?
>
> I am sorry if this has been already asked and answered here.
>
> Thanks in advance.

SELECT SUBSTR(column_name, 1, 35) column_name, constraint_name FROM user_cons_columns
WHERE constraint_name = (SELECT constraint_name

                         FROM user_constraints
                         WHERE UPPER(table_name) = UPPER('&TABLE_NAME')
                         AND constraint_type = 'P');

Copy and paste this query in sqlplus and you will be prompted for the table name.

Regards
/Rauf Sarwar Received on Sat May 17 2003 - 19:35:53 CDT

Original text of this message

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