| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to find out which column has the primary key?
Atif Ahmad Khan wrote:
>
> I am trying to find out which column in a table has the primary key.
> describe tablename doesn't show it. Any ideas?
>
> Thanks.
>
> Atif Khan
> aak2_at_ra.msstate.edu
You may query the data dictionary to find it out (for example EMP table):
SELECT UCC.COLUMN_NAME
FROM USER_CONSTRAINTS UC, USER_CONS_COLUMNS UCC
WHERE UC.TABLE_NAME = 'EMP'
AND UC.CONSTRAINT_TYPE = 'P'
AND UC.CONSTRAINT_NAME = UCC.CONSTRAINT_NAME
ORDER BY UCC.POSITION
An other way is to use a tool. If you like you may have a look
at http://ourworld.compuserve.com/homepages/keeptool .
We provide the tool Hora. It showes you much more about the database.
Received on Fri May 09 1997 - 00:00:00 CDT
![]() |
![]() |