All Forums Database
rlaskar 18 posts Joined 03/06
24 Mar 2006
Need to identigy Primary key from a table using Select

Hi,I was trying to identify the Primary keys from a table. I can doshow table tablename or help table tablename which would give me details about whole tables. Is it some command available to display PK or FK columns defined in a tableThanks,Rishab

24 Mar 2006

Rishab,There is nothing like a primary key in the tables.This is logical term, you will find this in sqlserver or oracle, but not in will find primary Index wich has nothing to do with primary key.if you create a Unique index on a table (or if you find one for a table) that can be considered as primary key.

dnoeth 4628 posts Joined 11/04
26 Mar 2006

Hi Rishab,if the table was created with a Primary Key constraint, it has been replaced by a UPI/USI. There's a PrimaryKeyIndexId in dbc.tables, which indicates the original PK and relates to dbc.indices.IndexNumber.In current releases there's also a "K" in dbc.indices.Indextype for a PK.For FKs there's dbc.all_ri_childrenDieter


27 Mar 2006

Thank you very much Dieter for the post.I am sorry for the answer i gave. Good to know this info.

You must sign in to leave a comment.