Find out the primary key of a table

Radu

Member
I need a simple way of finding out (in Delphi) the primary key fields (their names) of an Oracle table. I have only the table name.
I use Direct Oracle Access 3.4.6, Delphi 5 and Oracle 9i.
 
Try this:

select cc.column_name
from DBA_CONS_COLUMNS cc, DBA_CONSTRAINTS c
where c.owner = 'SYSTOOLS'
and c.table_name = 'SYST_RANG_RANGE'
and cc.owner = c.owner
and cc.constraint_name = c.constraint_name
and constraint_type = 'P'

Greetings
Jens
 
Thank you, but it appears that the query doesn't work for me.
In the meantime I found one that works:

select
cols.column_name
from
user_cons_columns cols, user_constraints cons
where
cols.constraint_name = cons.constraint_name and
cons.table_name = 'MY_TABLE_NAME' and cons.constraint_type = 'P'
order by
cols.position;
 
Back
Top