Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: newbie-desc command
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
![]() |
![]() |